nrf52: Add simple i2c test configuration
Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
This commit is contained in:
parent
11a842333f
commit
3a64783273
@ -370,7 +370,7 @@ static int nrf52_i2c_transfer(FAR struct i2c_master_s *dev,
|
||||
NRF52_TWIM_ERRORSRC_OFFSET) & 0x7;
|
||||
if (regval != 0)
|
||||
{
|
||||
i2cerr("Error SRC: %x\n", regval);
|
||||
i2cerr("Error SRC: 0x%08" PRIx32 "\n", regval);
|
||||
ret = -1;
|
||||
nrf52_i2c_putreg(priv,
|
||||
NRF52_TWIM_ERRORSRC_OFFSET, 0x7);
|
||||
@ -421,7 +421,7 @@ static int nrf52_i2c_transfer(FAR struct i2c_master_s *dev,
|
||||
NRF52_TWIM_ERRORSRC_OFFSET) & 0x7;
|
||||
if (regval != 0)
|
||||
{
|
||||
i2cerr("Error SRC: %x\n", regval);
|
||||
i2cerr("Error SRC: 0x%08" PRIx32 "\n", regval);
|
||||
ret = -1;
|
||||
nrf52_i2c_putreg(priv,
|
||||
NRF52_TWIM_ERRORSRC_OFFSET, 0x7);
|
||||
@ -468,7 +468,7 @@ static int nrf52_i2c_transfer(FAR struct i2c_master_s *dev,
|
||||
NRF52_TWIM_ERRORSRC_OFFSET) & 0x7;
|
||||
if (regval != 0)
|
||||
{
|
||||
i2cerr("Error SRC: %x\n", regval);
|
||||
i2cerr("Error SRC: 0x%08" PRIx32 "\n", regval);
|
||||
ret = -1;
|
||||
nrf52_i2c_putreg(priv,
|
||||
NRF52_TWIM_ERRORSRC_OFFSET, 0x7);
|
||||
|
50
boards/arm/nrf52/nrf52-feather/configs/i2c/defconfig
Normal file
50
boards/arm/nrf52/nrf52-feather/configs/i2c/defconfig
Normal file
@ -0,0 +1,50 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NSH_DISABLE_IFCONFIG is not set
|
||||
# CONFIG_NSH_DISABLE_PS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="nrf52-feather"
|
||||
CONFIG_ARCH_BOARD_NRF52_FEATHER=y
|
||||
CONFIG_ARCH_CHIP="nrf52"
|
||||
CONFIG_ARCH_CHIP_NRF52832=y
|
||||
CONFIG_ARCH_CHIP_NRF52=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_STDARG_H=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=5500
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_POLLED=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NRF52_I2C0_MASTER=y
|
||||
CONFIG_NRF52_UART0=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=65535
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=26
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYSTEM_I2CTOOL=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
@ -106,4 +106,9 @@
|
||||
#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(8))
|
||||
#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(6))
|
||||
|
||||
/* I2C Pins *****************************************************************/
|
||||
|
||||
#define BOARD_I2C0_SCL_PIN (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN(26))
|
||||
#define BOARD_I2C0_SDA_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(25))
|
||||
|
||||
#endif /* __BOARDS_ARM_NRF52_NRF52_FEATHER_INCLUDE_BOARD_H */
|
||||
|
@ -47,4 +47,8 @@ else
|
||||
CSRCS += nrf52_userleds.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_I2C),y)
|
||||
CSRCS += nrf52_i2c.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/boards/Board.mk
|
||||
|
@ -71,9 +71,33 @@
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
* Public Functions Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf52_i2c_register
|
||||
*
|
||||
* Description:
|
||||
* Register one I2C drivers for the I2C tool.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_I2C
|
||||
int nrf52_i2c_register(int bus);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf52_i2ctool
|
||||
*
|
||||
* Description:
|
||||
* Register I2C drivers for the I2C tool.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_I2CTOOL
|
||||
int nrf52_i2ctool(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf52_bringup
|
||||
*
|
||||
|
@ -50,6 +50,8 @@
|
||||
# include <nuttx/leds/userled.h>
|
||||
#endif
|
||||
|
||||
#include "nrf52-feather.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -92,6 +94,10 @@ int nrf52_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL)
|
||||
nrf52_i2ctool();
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
95
boards/arm/nrf52/nrf52-feather/src/nrf52_i2c.c
Normal file
95
boards/arm/nrf52/nrf52-feather/src/nrf52_i2c.c
Normal file
@ -0,0 +1,95 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/nrf52/nrf52-feather/src/nrf52_i2c.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#ifdef CONFIG_I2C
|
||||
# include "nrf52_i2c.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf52_i2c_register
|
||||
*
|
||||
* Description:
|
||||
* Register one I2C drivers for the I2C tool.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_I2C
|
||||
int nrf52_i2c_register(int bus)
|
||||
{
|
||||
struct i2c_master_s *i2c;
|
||||
int ret = OK;
|
||||
|
||||
i2c = nrf52_i2cbus_initialize(bus);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to get I2C%d interface\n", bus);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = i2c_register(i2c, bus);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to register I2C%d driver: %d\n",
|
||||
bus, ret);
|
||||
nrf52_i2cbus_uninitialize(i2c);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf52_i2ctool
|
||||
*
|
||||
* Description:
|
||||
* Register I2C drivers for the I2C tool.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_I2CTOOL
|
||||
int nrf52_i2ctool(void)
|
||||
{
|
||||
int ret = OK;
|
||||
#ifdef CONFIG_NRF52_I2C0_MASTER
|
||||
ret = nrf52_i2c_register(0);
|
||||
if (ret != OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NRF52_I2C1_MASTER
|
||||
ret = nrf52_i2c_register(0);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user