From 4ff4562401401a3a86c74cb2bda9a1a2b8d94e6d Mon Sep 17 00:00:00 2001 From: Lwazi Dube Date: Thu, 30 Mar 2023 10:38:59 -0400 Subject: [PATCH] tm4c1294-launchpad: Use bmi160 driver for boostxl-sensors. Use the preexisting bmi160 driver for the boostxl-sensors boosterpack. Add macros to allow the bluetooth module to be used with UART6. --- boards/arm/tiva/tm4c1294-launchpad/Kconfig | 16 +++++ .../tiva/tm4c1294-launchpad/include/board.h | 37 +++++++++--- .../tm4c1294-launchpad/src/tm4c_bringup.c | 60 +++++++++++++++++++ 3 files changed, 105 insertions(+), 8 deletions(-) diff --git a/boards/arm/tiva/tm4c1294-launchpad/Kconfig b/boards/arm/tiva/tm4c1294-launchpad/Kconfig index 27d881752a..942d50abe1 100644 --- a/boards/arm/tiva/tm4c1294-launchpad/Kconfig +++ b/boards/arm/tiva/tm4c1294-launchpad/Kconfig @@ -110,4 +110,20 @@ config TM4C1294_LAUNCHPAD_UART2_TX_D5 endchoice # UART2 Tx pin selection +choice + prompt "Sensors selection" + depends on TIVA_I2C + default BOOSTXL_SENSORS_NONE + +config BOOSTXL_SENSORS_NONE + bool "None" + +config BOOSTXL_SENSORS_1 + bool "BOOSTXL-SENSORS on BOOSTERPACK1" + depends on TIVA_I2C0 + +config BOOSTXL_SENSORS_2 + bool "BOOSTXL-SENSORS on BOOSTERPACK2" + depends on TIVA_I2C2 +endchoice endif # ARCH_BOARD_TM4C1294_LAUNCHPAD diff --git a/boards/arm/tiva/tm4c1294-launchpad/include/board.h b/boards/arm/tiva/tm4c1294-launchpad/include/board.h index a7b57c1907..fdff84956e 100644 --- a/boards/arm/tiva/tm4c1294-launchpad/include/board.h +++ b/boards/arm/tiva/tm4c1294-launchpad/include/board.h @@ -202,19 +202,40 @@ #define GPIO_UART2_TX GPIO_UART2_TX_1 #endif -/* Control pins for BOOST-CC2564MODA plugged into BoosterPack1 +/* Control pins for BOOST-CC2564MODA plugged into BoosterPack 1 or 2. * - * --- ------------ - * Pin Pin Function - * --- ------------ - * PM3 NSHUTD - * PG0 RTS - * PL4 CTS - * --- ------------ + * BoosterPack1 BoosterPack2 + * + * --- ------------ --- ------------ + * Pin Pin Function Pin Pin Function + * --- ------------ --- ------------ + * PM3 NSHUTD PM7 NSHUTD + * PG0 RTS PM0 RTS + * PL4 CTS PM1 CTS + * --- ------------ --- ------------ */ #define UART7_GPIO_NSHUTD (GPIO_FUNC_OUTPUT | GPIO_PORTM | GPIO_PIN_3) #define UART7_GPIO_RTS (GPIO_FUNC_OUTPUT | GPIO_PORTG | GPIO_PIN_0) #define UART7_GPIO_CTS (GPIO_FUNC_INPUT | GPIO_PORTL | GPIO_PIN_4) +#define UART6_GPIO_NSHUTD (GPIO_FUNC_OUTPUT | GPIO_PORTM | GPIO_PIN_7) +#define UART6_GPIO_RTS (GPIO_FUNC_OUTPUT | GPIO_PORTM | GPIO_PIN_0) +#define UART6_GPIO_CTS (GPIO_FUNC_INPUT | GPIO_PORTM | GPIO_PIN_1) + +/* Pins for I2C. + * + * BoosterPack1 I2C0 BoosterPack2 I2C2 + * + * --- ------------ --- ------------ + * Pin Pin Function Pin Pin Function + * --- ------------ --- ------------ + * PB2 SCL PN5 SCL + * PB3 SDA PN4 SDA + * --- ------------ --- ------------ + */ + +#define GPIO_I2C2_SCL GPIO_I2C2_SCL_3 +#define GPIO_I2C2_SDA GPIO_I2C2_SDA_2 + #endif /* __BOARDS_ARM_TIVA_TM4C1294_LAUNCHPAD_INCLUDE_BOARD_H */ diff --git a/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c b/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c index 5d73175e37..57e2644475 100644 --- a/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c +++ b/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -151,6 +152,46 @@ static void tm4c_i2ctool(void) # define tm4c_i2ctool() #endif +/**************************************************************************** + * Name: tm4c_bmi160_setup + * + * Description: + * Initialize and register the bmi160 sensor. + * + * Input Parameters: + * bus - A number identifying the I2C bus. + * + * Returned Value: + * On success, zero (OK) is returned. On failure, a negated errno value + * is returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_SENSORS_BMI160 +static int tm4c_bmi160_setup(int bus) +{ + int ret; + struct i2c_master_s *i2c; + + /* Initialize i2c device */ + + i2c = tiva_i2cbus_initialize(bus); + if (!i2c) + { + syslog(LOG_ERR, "ERROR: Failed to initialize i2c%d.\n", bus); + return -ENODEV; + } + + ret = bmi160_register("/dev/accel0", i2c); + if (ret < 0) + { + syslog(LOG_ERR, "Error registering BMI160\n"); + } + + return ret; +} +#endif + /**************************************************************************** * Name: tm4c_pwm_register * @@ -306,6 +347,25 @@ int tm4c_bringup(void) tm4c_i2ctool(); +#ifdef CONFIG_SENSORS_BMI160 +#if defined(CONFIG_BOOSTXL_SENSORS_1) + + ret = tm4c_bmi160_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: BMI160 on 1 failed %d\n", ret); + } +#endif +#if defined(CONFIG_BOOSTXL_SENSORS_2) + + ret = tm4c_bmi160_setup(2); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: BMI160 on 2 failed %d\n", ret); + } +#endif +#endif + #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */