This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 46cc145645fbbfa75c6a9a9c7bbc306b580b5082 Author: raiden00pl <[email protected]> AuthorDate: Fri Mar 8 14:13:11 2024 +0100 thingy91: initial sensors support initial sensors support for thingy91 Signed-off-by: raiden00pl <[email protected]> --- .../platforms/arm/nrf91/boards/thingy91/index.rst | 18 +- boards/arm/nrf91/common/include/nrf91_adxl362.h | 40 ++++ boards/arm/nrf91/common/include/nrf91_adxl372.h | 40 ++++ boards/arm/nrf91/common/include/nrf91_bh1749nuc.h | 40 ++++ boards/arm/nrf91/common/include/nrf91_bme680.h | 40 ++++ boards/arm/nrf91/common/src/CMakeLists.txt | 16 ++ boards/arm/nrf91/common/src/Make.defs | 16 ++ .../nrf91_boot.c => common/src/nrf91_adxl362.c} | 67 +++---- .../nrf91_boot.c => common/src/nrf91_adxl372.c} | 67 +++---- .../nrf91_boot.c => common/src/nrf91_bh1749nuc.c} | 79 ++++---- .../src/nrf91_boot.c => common/src/nrf91_bme680.c} | 88 +++++---- .../nrf91/thingy91/configs/thingy91_rtt/defconfig | 67 +++++++ boards/arm/nrf91/thingy91/src/CMakeLists.txt | 10 +- boards/arm/nrf91/thingy91/src/Make.defs | 10 +- boards/arm/nrf91/thingy91/src/nrf91_boot.c | 6 + boards/arm/nrf91/thingy91/src/nrf91_bringup.c | 14 ++ .../thingy91/src/{nrf91_boot.c => nrf91_i2c.c} | 97 +++++++--- .../src/{nrf91_bringup.c => nrf91_sensors.c} | 111 +++++------ boards/arm/nrf91/thingy91/src/nrf91_spi.c | 208 +++++++++++++++++++++ boards/arm/nrf91/thingy91/src/thingy91.h | 55 +++++- 20 files changed, 819 insertions(+), 270 deletions(-) diff --git a/Documentation/platforms/arm/nrf91/boards/thingy91/index.rst b/Documentation/platforms/arm/nrf91/boards/thingy91/index.rst index 7e6c1e26312..2af89956ef3 100644 --- a/Documentation/platforms/arm/nrf91/boards/thingy91/index.rst +++ b/Documentation/platforms/arm/nrf91/boards/thingy91/index.rst @@ -19,14 +19,14 @@ GPS No Buttons Yes LEDs No COEX No -PMIC No +PMIC (ADP5360) No I2C 0x46 Battery monitoring No Buzzer No -EEPROM (24CW160) No -Low power accelerometer (ADXL362) No -Hi G accelerometer (ADXL372) No -Air quality sensor (HBME680) No -Color sensor (BH1749NUC) No +EEPROM (24CW160) No I2C 0x50 +Low power accelerometer (ADXL362) No SPI +Hi G accelerometer (ADXL372) No SPI +Air quality sensor (BME680) No I2C 0x76 +Color sensor (BH1749NUC) No I2C 0x38 ================================== ======= ============= Serial Console @@ -39,7 +39,11 @@ Serial Console Configurations ============== -TODO +thingy91_rtt +------------ + +Configuration with a console over RTT, enabling available peripherals +on the board (WIP). Flash & Debug ============= diff --git a/boards/arm/nrf91/common/include/nrf91_adxl362.h b/boards/arm/nrf91/common/include/nrf91_adxl362.h new file mode 100644 index 00000000000..1d177bd3083 --- /dev/null +++ b/boards/arm/nrf91/common/include/nrf91_adxl362.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * boards/arm/nrf91/common/include/nrf91_adxl362.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_ADXL362_H +#define __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_ADXL362_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf91_adxl362_init + ****************************************************************************/ + +int nrf91_adxl362_init(int devno, int busno); + +#endif /* __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_ADXL362_H */ diff --git a/boards/arm/nrf91/common/include/nrf91_adxl372.h b/boards/arm/nrf91/common/include/nrf91_adxl372.h new file mode 100644 index 00000000000..8663494a5c7 --- /dev/null +++ b/boards/arm/nrf91/common/include/nrf91_adxl372.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * boards/arm/nrf91/common/include/nrf91_adxl372.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_ADXL372_H +#define __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_ADXL372_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf91_adxl372_init + ****************************************************************************/ + +int nrf91_adxl372_init(int devno, int busno); + +#endif /* __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_ADXL372_H */ diff --git a/boards/arm/nrf91/common/include/nrf91_bh1749nuc.h b/boards/arm/nrf91/common/include/nrf91_bh1749nuc.h new file mode 100644 index 00000000000..52045ef8330 --- /dev/null +++ b/boards/arm/nrf91/common/include/nrf91_bh1749nuc.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * boards/arm/nrf91/common/include/nrf91_bh1749nuc.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_BH1749NUC_H +#define __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_BH1749NUC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf91_bh1749nuc_init + ****************************************************************************/ + +int nrf91_bh1749nuc_init(int devno, int busno, uint8_t addr); + +#endif /* __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_BH1749NUC_H */ diff --git a/boards/arm/nrf91/common/include/nrf91_bme680.h b/boards/arm/nrf91/common/include/nrf91_bme680.h new file mode 100644 index 00000000000..714595ccf90 --- /dev/null +++ b/boards/arm/nrf91/common/include/nrf91_bme680.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * boards/arm/nrf91/common/include/nrf91_bme680.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_BME680_H +#define __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_BME680_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf91_bme680_init + ****************************************************************************/ + +int nrf91_bme680_init(int devno, int busno); + +#endif /* __BOARDS_ARM_NRF91_COMMON_INCLUDE_NRF91_BME680_H */ diff --git a/boards/arm/nrf91/common/src/CMakeLists.txt b/boards/arm/nrf91/common/src/CMakeLists.txt index d800cd1bb0a..3296b72afa4 100644 --- a/boards/arm/nrf91/common/src/CMakeLists.txt +++ b/boards/arm/nrf91/common/src/CMakeLists.txt @@ -38,6 +38,22 @@ if(CONFIG_ARCH_BOARD_COMMON) list(APPEND SRCS nrf91_reset.c) endif() + if(CONFIG_SENSORS_BH1749NUC) + list(APPEND SRCS nrf91_bh1749nuc.c) + endif() + + if(CONFIG_SENSORS_BME680) + list(APPEND SRCS nrf91_bme680.c) + endif() + + if(CONFIG_SENSORS_ADXL372) + list(APPEND SRCS nrf91_adxl372.c) + endif() + + if(CONFIG_SENSORS_ADXL362) + list(APPEND SRCS nrf91_adxl362.c) + endif() + target_sources(board PRIVATE ${SRCS}) endif() diff --git a/boards/arm/nrf91/common/src/Make.defs b/boards/arm/nrf91/common/src/Make.defs index 290b73bfa3b..279e7a40728 100644 --- a/boards/arm/nrf91/common/src/Make.defs +++ b/boards/arm/nrf91/common/src/Make.defs @@ -38,6 +38,22 @@ ifeq ($(CONFIG_BOARDCTL_RESET),y) CSRCS += nrf91_reset.c endif +ifeq ($(CONFIG_SENSORS_BH1749NUC),y) + CSRCS += nrf91_bh1749nuc.c +endif + +ifeq ($(CONFIG_SENSORS_BME680),y) + CSRCS += nrf91_bme680.c +endif + +ifeq ($(CONFIG_SENSORS_ADXL372),y) + CSRCS += nrf91_adxl372.c +endif + +ifeq ($(CONFIG_SENSORS_ADXL362),y) + CSRCS += nrf91_adxl362.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src diff --git a/boards/arm/nrf91/thingy91/src/nrf91_boot.c b/boards/arm/nrf91/common/src/nrf91_adxl362.c similarity index 50% copy from boards/arm/nrf91/thingy91/src/nrf91_boot.c copy to boards/arm/nrf91/common/src/nrf91_adxl362.c index 0450484bb95..9c5e33c5bc6 100644 --- a/boards/arm/nrf91/thingy91/src/nrf91_boot.c +++ b/boards/arm/nrf91/common/src/nrf91_adxl362.c @@ -1,7 +1,5 @@ /**************************************************************************** - * boards/arm/nrf91/thingy91/src/nrf91_boot.c - * - * SPDX-License-Identifier: Apache-2.0 + * boards/arm/nrf91/common/src/nrf91_adxl362.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,56 +24,45 @@ #include <nuttx/config.h> -#include <nuttx/debug.h> +#include <debug.h> +#include <errno.h> +#include <stdio.h> -#include <nuttx/board.h> -#include <arch/board/board.h> +#include <nuttx/spi/spi.h> +#include <nuttx/sensors/adxl362.h> -#include "arm_internal.h" -#include "thingy91.h" +#include "nrf91_spi.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: nrf91_board_initialize - * - * Description: - * All NRF91xxx architectures must provide the following entry point. - * This entry point is called early in the initialization -- after all - * memory has been configured and mapped but before any devices have been - * initialized. - * + * Name: nrf91_adxl362_init ****************************************************************************/ -void nrf91_board_initialize(void) +int nrf91_adxl362_init(int devno, int busno) { - /* Configure on-board LEDs if LED support has been selected. */ + struct spi_dev_s *spi; + int ret; -#ifdef CONFIG_ARCH_LEDS - board_autoled_initialize(); -#endif -} + sninfo("Initializing ADXL362!\n"); -/**************************************************************************** - * Name: board_late_initialize - * - * Description: - * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional - * initialization call will be performed in the boot-up sequence to a - * function called board_late_initialize(). board_late_initialize() will be - * called immediately after up_initialize() is called and just before the - * initial application is started. This additional initialization phase - * may be used, for example, to initialize board-specific device drivers. - * - ****************************************************************************/ + /* Initialize SPI */ -#ifdef CONFIG_BOARD_LATE_INITIALIZE -void board_late_initialize(void) -{ - /* Perform board-specific initialization */ + spi = nrf91_spibus_initialize(busno); + if (!spi) + { + return -ENODEV; + } + + /* Then register the barometer sensor */ + + ret = adxl362_register(devno, spi); + if (ret < 0) + { + snerr("ERROR: Error registering ADXL362\n"); + } - nrf91_bringup(); + return ret; } -#endif diff --git a/boards/arm/nrf91/thingy91/src/nrf91_boot.c b/boards/arm/nrf91/common/src/nrf91_adxl372.c similarity index 50% copy from boards/arm/nrf91/thingy91/src/nrf91_boot.c copy to boards/arm/nrf91/common/src/nrf91_adxl372.c index 0450484bb95..52c342435f7 100644 --- a/boards/arm/nrf91/thingy91/src/nrf91_boot.c +++ b/boards/arm/nrf91/common/src/nrf91_adxl372.c @@ -1,7 +1,5 @@ /**************************************************************************** - * boards/arm/nrf91/thingy91/src/nrf91_boot.c - * - * SPDX-License-Identifier: Apache-2.0 + * boards/arm/nrf91/common/src/nrf91_adxl372.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,56 +24,45 @@ #include <nuttx/config.h> -#include <nuttx/debug.h> +#include <debug.h> +#include <errno.h> +#include <stdio.h> -#include <nuttx/board.h> -#include <arch/board/board.h> +#include <nuttx/spi/spi.h> +#include <nuttx/sensors/adxl372.h> -#include "arm_internal.h" -#include "thingy91.h" +#include "nrf91_spi.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: nrf91_board_initialize - * - * Description: - * All NRF91xxx architectures must provide the following entry point. - * This entry point is called early in the initialization -- after all - * memory has been configured and mapped but before any devices have been - * initialized. - * + * Name: nrf91_adxl372_init ****************************************************************************/ -void nrf91_board_initialize(void) +int nrf91_adxl372_init(int devno, int busno) { - /* Configure on-board LEDs if LED support has been selected. */ + struct spi_dev_s *spi; + int ret; -#ifdef CONFIG_ARCH_LEDS - board_autoled_initialize(); -#endif -} + sninfo("Initializing ADXL372!\n"); -/**************************************************************************** - * Name: board_late_initialize - * - * Description: - * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional - * initialization call will be performed in the boot-up sequence to a - * function called board_late_initialize(). board_late_initialize() will be - * called immediately after up_initialize() is called and just before the - * initial application is started. This additional initialization phase - * may be used, for example, to initialize board-specific device drivers. - * - ****************************************************************************/ + /* Initialize SPI */ -#ifdef CONFIG_BOARD_LATE_INITIALIZE -void board_late_initialize(void) -{ - /* Perform board-specific initialization */ + spi = nrf91_spibus_initialize(busno); + if (!spi) + { + return -ENODEV; + } + + /* Then register the barometer sensor */ + + ret = adxl372_register_uorb(devno, spi); + if (ret < 0) + { + snerr("ERROR: Error registering ADXL372\n"); + } - nrf91_bringup(); + return ret; } -#endif diff --git a/boards/arm/nrf91/thingy91/src/nrf91_boot.c b/boards/arm/nrf91/common/src/nrf91_bh1749nuc.c similarity index 56% copy from boards/arm/nrf91/thingy91/src/nrf91_boot.c copy to boards/arm/nrf91/common/src/nrf91_bh1749nuc.c index 0450484bb95..d8c7006bc7d 100644 --- a/boards/arm/nrf91/thingy91/src/nrf91_boot.c +++ b/boards/arm/nrf91/common/src/nrf91_bh1749nuc.c @@ -1,7 +1,5 @@ /**************************************************************************** - * boards/arm/nrf91/thingy91/src/nrf91_boot.c - * - * SPDX-License-Identifier: Apache-2.0 + * boards/arm/nrf91/common/src/nrf91_bh1749nuc.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,56 +24,57 @@ #include <nuttx/config.h> -#include <nuttx/debug.h> +#include <debug.h> +#include <errno.h> +#include <stdio.h> + +#include <nuttx/i2c/i2c_master.h> +#include <nuttx/sensors/bh1749nuc.h> + +#include "nrf91_i2c.h" -#include <nuttx/board.h> -#include <arch/board/board.h> +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ -#include "arm_internal.h" -#include "thingy91.h" +#ifndef CONFIG_SENSORS_BH1749NUC_UORB +# error BH1749NUC UORB is only supported +#endif /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: nrf91_board_initialize - * - * Description: - * All NRF91xxx architectures must provide the following entry point. - * This entry point is called early in the initialization -- after all - * memory has been configured and mapped but before any devices have been - * initialized. - * + * Name: nrf91_bh1749nuc_init ****************************************************************************/ -void nrf91_board_initialize(void) +int nrf91_bh1749nuc_init(int devno, int busno, uint8_t addr) { - /* Configure on-board LEDs if LED support has been selected. */ + struct bh1749nuc_config_s config; + struct i2c_master_s *i2c; + int ret; -#ifdef CONFIG_ARCH_LEDS - board_autoled_initialize(); -#endif -} + sninfo("Initializing BH1749NUC!\n"); -/**************************************************************************** - * Name: board_late_initialize - * - * Description: - * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional - * initialization call will be performed in the boot-up sequence to a - * function called board_late_initialize(). board_late_initialize() will be - * called immediately after up_initialize() is called and just before the - * initial application is started. This additional initialization phase - * may be used, for example, to initialize board-specific device drivers. - * - ****************************************************************************/ + /* Initialize I2C */ -#ifdef CONFIG_BOARD_LATE_INITIALIZE -void board_late_initialize(void) -{ - /* Perform board-specific initialization */ + i2c = nrf91_i2cbus_initialize(busno); + if (!i2c) + { + return -ENODEV; + } - nrf91_bringup(); + /* Then register the barometer sensor */ + + config.i2c = i2c; + config.addr = addr; + + ret = bh1749nuc_register_uorb(devno, &config); + if (ret < 0) + { + snerr("ERROR: Error registering BH1749NUC\n"); + } + + return ret; } -#endif diff --git a/boards/arm/nrf91/thingy91/src/nrf91_boot.c b/boards/arm/nrf91/common/src/nrf91_bme680.c similarity index 55% copy from boards/arm/nrf91/thingy91/src/nrf91_boot.c copy to boards/arm/nrf91/common/src/nrf91_bme680.c index 0450484bb95..5b0417589d0 100644 --- a/boards/arm/nrf91/thingy91/src/nrf91_boot.c +++ b/boards/arm/nrf91/common/src/nrf91_bme680.c @@ -1,7 +1,5 @@ /**************************************************************************** - * boards/arm/nrf91/thingy91/src/nrf91_boot.c - * - * SPDX-License-Identifier: Apache-2.0 + * boards/arm/nrf91/common/src/nrf91_bme680.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,56 +24,66 @@ #include <nuttx/config.h> -#include <nuttx/debug.h> +#include <debug.h> +#include <errno.h> +#include <stdio.h> -#include <nuttx/board.h> -#include <arch/board/board.h> +#include <nuttx/i2c/i2c_master.h> +#include <nuttx/sensors/bme680.h> -#include "arm_internal.h" -#include "thingy91.h" +#include "nrf91_i2c.h" /**************************************************************************** - * Public Functions + * Private data ****************************************************************************/ -/**************************************************************************** - * Name: nrf91_board_initialize - * - * Description: - * All NRF91xxx architectures must provide the following entry point. - * This entry point is called early in the initialization -- after all - * memory has been configured and mapped but before any devices have been - * initialized. - * - ****************************************************************************/ +/* Default measurement configuration. Without a configuration the driver + * never leaves the "not calibrated" state and no measurements are taken. + * Oversampling follows the Bosch "indoor navigation" recommendation; the + * gas heater profile targets 320 C for 150 ms. + */ -void nrf91_board_initialize(void) +struct bme680_config_s g_bme680_config = { - /* Configure on-board LEDs if LED support has been selected. */ + .temp_os = BME680_OS_8X, + .press_os = BME680_OS_4X, + .hum_os = BME680_OS_2X, + .target_temp = 320, + .heater_duration = 150, + .nb_conv = 0, + .amb_temp = 25, +}; -#ifdef CONFIG_ARCH_LEDS - board_autoled_initialize(); -#endif -} +/**************************************************************************** + * Public Functions + ****************************************************************************/ /**************************************************************************** - * Name: board_late_initialize - * - * Description: - * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional - * initialization call will be performed in the boot-up sequence to a - * function called board_late_initialize(). board_late_initialize() will be - * called immediately after up_initialize() is called and just before the - * initial application is started. This additional initialization phase - * may be used, for example, to initialize board-specific device drivers. - * + * Name: nrf91_bme680_init ****************************************************************************/ -#ifdef CONFIG_BOARD_LATE_INITIALIZE -void board_late_initialize(void) +int nrf91_bme680_init(int devno, int busno) { - /* Perform board-specific initialization */ + struct i2c_master_s *i2c; + int ret; + + sninfo("Initializing BME680!\n"); + + /* Initialize I2C */ + + i2c = nrf91_i2cbus_initialize(busno); + if (!i2c) + { + return -ENODEV; + } + + /* Then register the barometer sensor */ + + ret = bme680_register(devno, i2c, &g_bme680_config); + if (ret < 0) + { + snerr("ERROR: Error registering BME680\n"); + } - nrf91_bringup(); + return ret; } -#endif diff --git a/boards/arm/nrf91/thingy91/configs/thingy91_rtt/defconfig b/boards/arm/nrf91/thingy91/configs/thingy91_rtt/defconfig new file mode 100644 index 00000000000..5476f2c9f4e --- /dev/null +++ b/boards/arm/nrf91/thingy91/configs/thingy91_rtt/defconfig @@ -0,0 +1,67 @@ +# +# 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_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="thingy91" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_THINGY91=y +CONFIG_ARCH_CHIP="nrf91" +CONFIG_ARCH_CHIP_NRF9160=y +CONFIG_ARCH_CHIP_NRF91=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_ARCH_TRUSTZONE_SECURE=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SENSORS=y +CONFIG_DEBUG_SENSORS_ERROR=y +CONFIG_DEBUG_SENSORS_INFO=y +CONFIG_DEBUG_SENSORS_WARN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_UORB=y +CONFIG_EXPERIMENTAL=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NDEBUG=y +CONFIG_NRF91_SPI1_MASTER=y +CONFIG_NRF91_SPI_MASTER_INTERRUPTS=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SENSORS=y +CONFIG_SENSORS_ADXL372=y +CONFIG_SENSORS_ADXL372_UORB=y +CONFIG_SERIAL_RTT0=y +CONFIG_STACK_CANARIES=y +CONFIG_STACK_COLORATION=y +CONFIG_STACK_USAGE=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSLOG_RTT=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UORB=y +CONFIG_UORB_ALERT=y +CONFIG_UORB_ERROR=y +CONFIG_UORB_INFO=y +CONFIG_UORB_LISTENER=y +CONFIG_UORB_WARN=y +CONFIG_USENSOR=y diff --git a/boards/arm/nrf91/thingy91/src/CMakeLists.txt b/boards/arm/nrf91/thingy91/src/CMakeLists.txt index 991764c8e78..b3ec909aaf5 100644 --- a/boards/arm/nrf91/thingy91/src/CMakeLists.txt +++ b/boards/arm/nrf91/thingy91/src/CMakeLists.txt @@ -20,12 +20,20 @@ # # ############################################################################## -set(SRCS nrf91_boot.c nrf91_bringup.c) +set(SRCS nrf91_boot.c nrf91_bringup.c nrf91_sensors.c) if(CONFIG_ARCH_BUTTONS) list(APPEND SRCS nrf91_buttons.c) endif() +if(CONFIG_NRF91_SPI_MASTER) + list(APPEND SRCS nrf91_spi.c) +endif() + +if(CONFIG_I2C) + list(APPEND SRCS nrf91_i2c.c) +endif() + if(CONFIG_NRF91_MODEM) list(APPEND SRCS nrf91_modem.c) endif() diff --git a/boards/arm/nrf91/thingy91/src/Make.defs b/boards/arm/nrf91/thingy91/src/Make.defs index 599f6f5a9b8..d68245956ef 100644 --- a/boards/arm/nrf91/thingy91/src/Make.defs +++ b/boards/arm/nrf91/thingy91/src/Make.defs @@ -22,7 +22,7 @@ include $(TOPDIR)/Make.defs -CSRCS = nrf91_boot.c nrf91_bringup.c +CSRCS = nrf91_boot.c nrf91_bringup.c nrf91_sensors.c ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += nrf91_buttons.c @@ -32,6 +32,14 @@ ifeq ($(CONFIG_NRF91_MODEM),y) CSRCS += nrf91_modem.c endif +ifeq ($(CONFIG_NRF91_SPI_MASTER),y) +CSRCS += nrf91_spi.c +endif + +ifeq ($(CONFIG_I2C),y) +CSRCS += nrf91_i2c.c +endif + DEPPATH += --dep-path board VPATH += :board CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board diff --git a/boards/arm/nrf91/thingy91/src/nrf91_boot.c b/boards/arm/nrf91/thingy91/src/nrf91_boot.c index 0450484bb95..a5e2cdcf4f3 100644 --- a/boards/arm/nrf91/thingy91/src/nrf91_boot.c +++ b/boards/arm/nrf91/thingy91/src/nrf91_boot.c @@ -56,6 +56,12 @@ void nrf91_board_initialize(void) #ifdef CONFIG_ARCH_LEDS board_autoled_initialize(); #endif + +#ifdef CONFIG_NRF91_SPI_MASTER + /* Configure SPI chip selects */ + + nrf91_spidev_initialize(); +#endif } /**************************************************************************** diff --git a/boards/arm/nrf91/thingy91/src/nrf91_bringup.c b/boards/arm/nrf91/thingy91/src/nrf91_bringup.c index 9c80e57eb44..4d52425598d 100644 --- a/boards/arm/nrf91/thingy91/src/nrf91_bringup.c +++ b/boards/arm/nrf91/thingy91/src/nrf91_bringup.c @@ -87,6 +87,10 @@ int nrf91_bringup(void) { int ret; +#if defined(CONFIG_I2C) && defined(CONFIG_SYSTEM_I2CTOOL) + nrf91_i2ctool(); +#endif + #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ @@ -120,6 +124,16 @@ int nrf91_bringup(void) } #endif + /* Initialzie on-board sensors */ + + ret = nrf91_sensors_init(); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to initialize sensors: %d\n", + ret); + } + #ifdef CONFIG_NRF91_MODEM /* Initialize modem */ diff --git a/boards/arm/nrf91/thingy91/src/nrf91_boot.c b/boards/arm/nrf91/thingy91/src/nrf91_i2c.c similarity index 56% copy from boards/arm/nrf91/thingy91/src/nrf91_boot.c copy to boards/arm/nrf91/thingy91/src/nrf91_i2c.c index 0450484bb95..d76554d1318 100644 --- a/boards/arm/nrf91/thingy91/src/nrf91_boot.c +++ b/boards/arm/nrf91/thingy91/src/nrf91_i2c.c @@ -1,7 +1,5 @@ /**************************************************************************** - * boards/arm/nrf91/thingy91/src/nrf91_boot.c - * - * SPDX-License-Identifier: Apache-2.0 + * boards/arm/nrf91/thingy91/src/nrf91_i2c.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,56 +24,95 @@ #include <nuttx/config.h> -#include <nuttx/debug.h> - -#include <nuttx/board.h> -#include <arch/board/board.h> +#include <syslog.h> -#include "arm_internal.h" -#include "thingy91.h" +#ifdef CONFIG_I2C +# include "nrf91_i2c.h" +#endif /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: nrf91_board_initialize + * Name: nrf91_i2c_register * * Description: - * All NRF91xxx architectures must provide the following entry point. - * This entry point is called early in the initialization -- after all - * memory has been configured and mapped but before any devices have been - * initialized. + * Register one I2C drivers for the I2C tool. * ****************************************************************************/ -void nrf91_board_initialize(void) +#ifdef CONFIG_SYSTEM_I2CTOOL +int nrf91_i2c_register(int bus) { - /* Configure on-board LEDs if LED support has been selected. */ + struct i2c_master_s *i2c; + int ret = OK; -#ifdef CONFIG_ARCH_LEDS - board_autoled_initialize(); -#endif + i2c = nrf91_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); + nrf91_i2cbus_uninitialize(i2c); + } + } + + return ret; } +#endif /**************************************************************************** - * Name: board_late_initialize + * Name: nrf91_i2ctool * * Description: - * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional - * initialization call will be performed in the boot-up sequence to a - * function called board_late_initialize(). board_late_initialize() will be - * called immediately after up_initialize() is called and just before the - * initial application is started. This additional initialization phase - * may be used, for example, to initialize board-specific device drivers. + * Register I2C drivers for the I2C tool. * ****************************************************************************/ -#ifdef CONFIG_BOARD_LATE_INITIALIZE -void board_late_initialize(void) +#ifdef CONFIG_SYSTEM_I2CTOOL +int nrf91_i2ctool(void) { - /* Perform board-specific initialization */ + int ret = OK; + +#ifdef CONFIG_NRF91_I2C0_MASTER + ret = nrf91_i2c_register(0); + if (ret != OK) + { + return ret; + } +#endif + +#ifdef CONFIG_NRF91_I2C1_MASTER + ret = nrf91_i2c_register(1); + if (ret != OK) + { + return ret; + } +#endif + +#ifdef CONFIG_NRF91_I2C2_MASTER + ret = nrf91_i2c_register(2); + if (ret != OK) + { + return ret; + } +#endif + +#ifdef CONFIG_NRF91_I2C3_MASTER + ret = nrf91_i2c_register(3); + if (ret != OK) + { + return ret; + } +#endif - nrf91_bringup(); + return ret; } #endif diff --git a/boards/arm/nrf91/thingy91/src/nrf91_bringup.c b/boards/arm/nrf91/thingy91/src/nrf91_sensors.c similarity index 52% copy from boards/arm/nrf91/thingy91/src/nrf91_bringup.c copy to boards/arm/nrf91/thingy91/src/nrf91_sensors.c index 9c80e57eb44..880c3bb61d7 100644 --- a/boards/arm/nrf91/thingy91/src/nrf91_bringup.c +++ b/boards/arm/nrf91/thingy91/src/nrf91_sensors.c @@ -1,7 +1,5 @@ /**************************************************************************** - * boards/arm/nrf91/thingy91/src/nrf91_bringup.c - * - * SPDX-License-Identifier: Apache-2.0 + * boards/arm/nrf91/thingy91/src/nrf91_sensors.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -30,30 +28,20 @@ #include <sys/types.h> #include <syslog.h> -#include <nuttx/fs/fs.h> - -#ifdef CONFIG_USERLED -# include <nuttx/leds/userled.h> -#endif - -#ifdef CONFIG_INPUT_BUTTONS -# include <nuttx/input/buttons.h> -#endif - -#ifdef CONFIG_NRF91_MODEM -# include "nrf91_modem.h" +#ifdef CONFIG_SENSORS_BH1749NUC +# include "nrf91_bh1749nuc.h" #endif -#ifdef CONFIG_NRF91_MODEM_AT -# include "nrf91_modem_at.h" +#ifdef CONFIG_SENSORS_BME680 +# include "nrf91_bme680.h" #endif -#ifdef CONFIG_NRF91_PROGMEM -# include "nrf91_progmem.h" +#ifdef CONFIG_SENSORS_ADXL362 +# include "nrf91_adxl362.h" #endif -#ifdef CONFIG_TIMER -# include "nrf91_timer.h" +#ifdef CONFIG_SENSORS_ADXL372 +# include "nrf91_adxl372.h" #endif #include "thingy91.h" @@ -62,7 +50,13 @@ * Pre-processor Definitions ****************************************************************************/ -#define NRF91_TIMER (0) +#define BH1749NUC_I2C_ADDR 0x38 +#define BH1749NUC_I2C_BUS 2 + +#define BME680_I2C_BUS 2 + +#define ADXL372_SPI_BUS 1 +#define ADXL362_SPI_BUS 1 /**************************************************************************** * Private Functions @@ -73,83 +67,64 @@ ****************************************************************************/ /**************************************************************************** - * Name: nrf91_bringup + * Name: nrf91_sensors_init * * Description: - * Perform architecture-specific initialization - * - * CONFIG_BOARD_LATE_INITIALIZE=y : - * Called from board_late_initialize(). + * Initialzie on-board sensors * ****************************************************************************/ -int nrf91_bringup(void) +int nrf91_sensors_init(void) { - int ret; + int ret = OK; -#ifdef CONFIG_FS_PROCFS - /* Mount the procfs file system */ + UNUSED(ret); - ret = nx_mount(NULL, NRF91_PROCFS_MOUNTPOINT, "procfs", 0, NULL); - if (ret < 0) - { - syslog(LOG_ERR, - "ERROR: Failed to mount the PROC filesystem: %d\n", ret); - } -#endif /* CONFIG_FS_PROCFS */ +#ifdef CONFIG_SENSORS_BH1749NUC + nrf91_gpio_config(GPIO_BH1749_INT); -#ifdef CONFIG_INPUT_BUTTONS - /* Register the BUTTON driver */ + /* Initialize BH1749NUC */ - ret = btn_lower_initialize("/dev/buttons"); + ret = nrf91_bh1749nuc_init(0, BH1749NUC_I2C_BUS, BH1749NUC_I2C_ADDR); if (ret < 0) { - syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); + syslog(LOG_ERR, "ERROR: nrf91_bh1749nuc_init failed: %d\n", ret); } #endif -#if defined(CONFIG_TIMER) && defined(CONFIG_NRF91_TIMER) - /* Configure TIMER driver */ +#ifdef CONFIG_SENSORS_BME680 + /* Initialize BME680 */ - ret = nrf91_timer_driver_setup("/dev/timer0", NRF91_TIMER); + ret = nrf91_bme680_init(0, BME680_I2C_BUS); if (ret < 0) { - syslog(LOG_ERR, - "ERROR: Failed to initialize timer driver: %d\n", - ret); + syslog(LOG_ERR, "ERROR: nrf91_bme680_init failed: %d\n", ret); } #endif -#ifdef CONFIG_NRF91_MODEM - /* Initialize modem */ +#ifdef CONFIG_SENSORS_ADXL372 + nrf91_gpio_config(GPIO_ADXL372_INT1); - ret = nrf91_modem_initialize(); + /* Initialize ADXL372 */ + + ret = nrf91_adxl372_init(ADXL372_SPI_DEVNO, ADXL372_SPI_BUS); if (ret < 0) { - syslog(LOG_ERR, - "ERROR: Failed to initialize modem%d\n", ret); + syslog(LOG_ERR, "ERROR: nrf91_adxl372_init failed: %d\n", ret); } #endif -#ifdef CONFIG_NRF91_MODEM_AT - /* Initialize modem AT interface */ +#ifdef CONFIG_SENSORS_ADXL362 + nrf91_gpio_config(GPIO_ADXL362_INT1); - ret = nrf91_at_register("/dev/modem"); - if (ret < 0) - { - syslog(LOG_ERR, - "ERROR: Failed to initialize AT interface%d\n", ret); - } -#endif + /* Initialize ADXL362 */ -#ifdef CONFIG_NRF91_PROGMEM - ret = nrf91_progmem_init(); + ret = nrf91_adxl362_init(ADXL362_SPI_DEVNO, ADXL362_SPI_BUS); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize MTD progmem: %d\n", ret); + syslog(LOG_ERR, "ERROR: nrf91_adxl362_init failed: %d\n", ret); } -#endif /* CONFIG_MTD */ +#endif - UNUSED(ret); - return OK; + return ret; } diff --git a/boards/arm/nrf91/thingy91/src/nrf91_spi.c b/boards/arm/nrf91/thingy91/src/nrf91_spi.c new file mode 100644 index 00000000000..420b19d6ec9 --- /dev/null +++ b/boards/arm/nrf91/thingy91/src/nrf91_spi.c @@ -0,0 +1,208 @@ +/**************************************************************************** + * boards/arm/nrf91/thingy91/src/nrf91_spi.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 <stdint.h> +#include <stdbool.h> +#include <errno.h> +#include <debug.h> + +#include <nuttx/spi/spi.h> + +#include "arm_internal.h" +#include "chip.h" +#include "nrf91_gpio.h" +#include "nrf91_spi.h" + +#include "thingy91.h" +#include <arch/board/board.h> + +#ifdef CONFIG_NRF91_SPI_MASTER + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf91_spidev_initialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the Nucleo-144 board. + * + ****************************************************************************/ + +void nrf91_spidev_initialize(void) +{ +#ifdef CONFIG_NRF91_SPI1_MASTER + nrf91_gpio_config(GPIO_ADXL372_CS); + nrf91_gpio_write(GPIO_ADXL372_CS, true); + + nrf91_gpio_config(GPIO_ADXL362_CS); + nrf91_gpio_write(GPIO_ADXL362_CS, true); +#endif +} + +/**************************************************************************** + * Name: nrf91_spi0/1/2/3/select and nrf91_spi0/1/2/3/status + * + * Description: + * The external functions, nrf91_spi0/1/2/3select and + * nrf91_spi0/1/2/3status must be provided by board-specific logic. + * They are implementations of the select and status methods of the SPI + * interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h). + * All other methods (including nrf91_spibus_initialize()) are provided + * by common NRF91 logic. To use this common SPI logic on your board: + * + * 1. Provide logic in nrf91_boardinitialize() to configure SPI chip select + * pins. + * 2. Provide nrf91_spi0/1/2/3select() and nrf91_spi0/1/2/3status() + * functions in your board-specific logic. These functions will perform + * chip selection and status operations using GPIOs in the way your + * board is configured. + * 3. Add a calls to nrf91_spibus_initialize() in your low level + * application initialization logic + * 4. The handle returned by nrf91_spibus_initialize() may then be used to + * bind the SPI driver to higher level logic (e.g., calling + * mmcsd_spislotinitialize(), for example, will bind the SPI driver to + * the SPI MMC/SD driver). + * + ****************************************************************************/ + +#ifdef CONFIG_NRF91_SPI0_MASTER +void nrf91_spi0select(struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %08lx CS: %s\n", + (unsigned long)devid, selected ? "assert" : "de-assert"); +} + +uint8_t nrf91_spi0status(struct spi_dev_s *dev, uint32_t devid) +{ + return 0; +} +#endif + +#ifdef CONFIG_NRF91_SPI1_MASTER +void nrf91_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected) +{ + spiinfo("devid: %08lx CS: %s\n", (unsigned long)devid, + selected ? "assert" : "de-assert"); + + switch (devid) + { +#ifdef CONFIG_SENSORS_ADXL372 + case SPIDEV_ACCELEROMETER(ADXL372_SPI_DEVNO): + { + spiinfo("ADXL372 device %s\n", + selected ? "asserted" : "de-asserted"); + + /* Set the GPIO low to select and high to de-select */ + + nrf91_gpio_write(GPIO_ADXL372_CS, !selected); + break; + } +#endif + +#ifdef CONFIG_SENSORS_ADXL362 + case SPIDEV_ACCELEROMETER(ADXL362_SPI_DEVNO): + { + spiinfo("ADXL372 device %s\n", + selected ? "asserted" : "de-asserted"); + + /* Set the GPIO low to select and high to de-select */ + + nrf91_gpio_write(GPIO_ADXL362_CS, !selected); + break; + } +#endif + + default: + { + break; + } + } +} + +uint8_t nrf91_spi1status(struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t status = 0; + + switch (devid) + { +#ifdef CONFIG_SENSORS_ADXL372 + case SPIDEV_ACCELEROMETER(ADXL372_SPI_DEVNO): + { + status |= SPI_STATUS_PRESENT; + break; + } +#endif + +#ifdef CONFIG_SENSORS_ADXL362 + case SPIDEV_ACCELEROMETER(ADXL362_SPI_DEVNO): + { + status |= SPI_STATUS_PRESENT; + break; + } +#endif + + default: + { + break; + } + } + + return status; +} +#endif + +#ifdef CONFIG_nrf91_SPI2_MASTER +void nrf91_spi2select(struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %08lx CS: %s\n", + (unsigned long)devid, selected ? "assert" : "de-assert"); +} + +uint8_t nrf91_spi2status(struct spi_dev_s *dev, uint32_t devid) +{ + return 0; +} +#endif + +#ifdef CONFIG_NRF91_SPI3_MASTER +void nrf91_spi3select(struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %08lx CS: %s\n", + (unsigned long)devid, selected ? "assert" : "de-assert"); +} + +uint8_t nrf91_spi3status(struct spi_dev_s *dev, uint32_t devid) +{ + return 0; +} +#endif + +#endif /* CONFIG_NRF91_SPI_MASTER */ diff --git a/boards/arm/nrf91/thingy91/src/thingy91.h b/boards/arm/nrf91/thingy91/src/thingy91.h index 381e90736c2..26cef5ca962 100644 --- a/boards/arm/nrf91/thingy91/src/thingy91.h +++ b/boards/arm/nrf91/thingy91/src/thingy91.h @@ -67,12 +67,13 @@ /* Supported devices ********************************************************/ /* ADXL372 - * INT1 - P0.09 - * CS - P0.08 + * INT1 - P0.06 + * CS - P0.07 */ #define GPIO_ADXL372_INT1 (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(6)) #define GPIO_ADXL372_CS (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(7)) +#define ADXL372_SPI_DEVNO 0 /* ADXL362 * INT1 - P0.09 @@ -81,8 +82,9 @@ #define GPIO_ADXL362_INT1 (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(9)) #define GPIO_ADXL362_CS (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(8)) +#define ADXL362_SPI_DEVNO 1 -/* BH1749 +/* BH1749NUC * INT - P0.27 */ @@ -121,5 +123,52 @@ int nrf91_bringup(void); +/**************************************************************************** + * Name: nrf91_sensors_init + * + * Description: + * Initialzie on-board sensors + * + ****************************************************************************/ + +int nrf91_sensors_init(void); + +/**************************************************************************** + * Name: nrf91_i2c_register + * + * Description: + * Register one I2C drivers for the I2C tool. + * + ****************************************************************************/ + +#ifdef CONFIG_I2C +int nrf91_i2c_register(int bus); +#endif + +/**************************************************************************** + * Name: nrf91_i2ctool + * + * Description: + * Register I2C drivers for the I2C tool. + * + ****************************************************************************/ + +#ifdef CONFIG_SYSTEM_I2CTOOL +int nrf91_i2ctool(void); +#endif + +/**************************************************************************** + * Name: nrf91_spidev_initialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the + * thingy91 board. + * + ****************************************************************************/ + +#ifdef CONFIG_NRF91_SPI_MASTER +void nrf91_spidev_initialize(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __BOARDS_ARM_NRF91_THINGY91_SRC_THINGY91_H */
