diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 8fe6d3857ee..5e85f3d9683 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: November 14, 2018

+

Last Updated: November 18, 2018

@@ -1530,7 +1530,7 @@
  • ARM Cortex-R4 (2)
  • ARM Cortex-M0/M0+ (10)
  • ARM Cortex-M3 (37)
  • -
  • ARM Cortex-M4 (49)
  • +
  • ARM Cortex-M4 (50)
  • ARM Cortex-M7 (13)
  • Atmel AVR @@ -3793,11 +3793,16 @@ nsh> Nordic Semiconductor/NRF52xxx. Initial architecture support of the NRF52 including UART, Timer, and GPIOs was contributed by Janne Rosberg in NuttX-7.25. Janne also contributed board support for the NRF52-PCA10040 development board at that time. - Additional drivers include: +

    +

    + The NRF52 was generalized by Hanya Zou in NuttX-7.28 for any similar board based on the NRF52832 MCU. Support was specifically included for the Adafruit NRF52 Feather board. +

    +

    + Available drivers include:

    - -
  • STMicro STM32F334 (STM32 F3 family, ARM Cortex-M4)
  • -

    @@ -4082,8 +4070,8 @@ nsh>

    - STMicro STM32 STM32F334 (STM32 F3 family, ARM Cortex-M4). -

    + STMicro STM32 F334 (STM32 F3 family, ARM Cortex-M4). +

    Support for the STMicro STM32F334-Disco board was contributed by Mateusz Szafoni in NuttX-7.22 and for the Nucleo-STM32F334R8 was contributed in an earlier release.

    @@ -5240,9 +5228,6 @@ Mem: 29232 5920 23312 23312

    - -
  • Atmel SAMD5x/E5x (ARM Cortex-M4)
  • -

    diff --git a/Documentation/README.html b/Documentation/README.html index 782dd278be6..a4be2082dc2 100644 --- a/Documentation/README.html +++ b/Documentation/README.html @@ -8,7 +8,7 @@

    NuttX README Files

    -

    Last Updated: November 17, 2018

    +

    Last Updated: November 18, 2018

    @@ -173,8 +173,8 @@ nuttx/ | | `- README.txt | |- ne64badge/ | | `- README.txt - | |- nrf52-pca10040/ - | | `- README.txt + | |- nrf52-generic/ + | | `- README.txt | |- ntosd-dm320/ | | |- doc/README.txt | | `- README.txt diff --git a/README.txt b/README.txt index 98b0c28d217..67f0ea77355 100644 --- a/README.txt +++ b/README.txt @@ -1847,7 +1847,7 @@ nuttx/ | | `- README.txt | |- ne63badge/ | | `- README.txt - | |- nrf52-pca10040/ + | |- nrf52-generic/ | | `- README.txt | |- ntosd-dm320/ | | |- doc/README.txt diff --git a/arch/arm/src/nrf52/nrf52_gpio.h b/arch/arm/src/nrf52/nrf52_gpio.h index 9b506128e0e..c96fe5b4306 100644 --- a/arch/arm/src/nrf52/nrf52_gpio.h +++ b/arch/arm/src/nrf52/nrf52_gpio.h @@ -174,6 +174,7 @@ # define GPIO_PIN29 (29 << GPIO_PIN_SHIFT) # define GPIO_PIN30 (30 << GPIO_PIN_SHIFT) # define GPIO_PIN31 (31 << GPIO_PIN_SHIFT) +# define GPIO_PIN(n) ((n) << GPIO_PIN_SHIFT) /************************************************************************************ * Public Types diff --git a/configs/Kconfig b/configs/Kconfig index 9df05d5ee86..dc265ba2a0c 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -553,6 +553,17 @@ config ARCH_BOARD_NRF52_PCA10040 ---help--- PCA10040 Evaluation board +config ARCH_BOARD_NRF52_GENERIC + bool "Generic NRF52832 board" + depends on ARCH_CHIP_NRF52 + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + ---help--- + NuttX port to the a generic NRF52832 board. Support is in place for + the NRF PCA10040 board from Nordic Semiconductor or for the Adafruit + NRF52 feather and can be simply extended to other board based on the + NRF52832 MCU. + config ARCH_BOARD_LPC1766STK bool "Olimex LPC1766-STK board" depends on ARCH_CHIP_LPC1766 @@ -1755,7 +1766,7 @@ config ARCH_BOARD default "misoc" if ARCH_BOARD_MISOC default "moteino-mega" if ARCH_BOARD_MOTEINO_MEGA default "ne64badge" if ARCH_BOARD_NE64BADGE - default "nrf52-pca10040" if ARCH_BOARD_NRF52_PCA10040 + default "nrf52-generic" if ARCH_BOARD_NRF52_GENERIC default "ntosd-dm320" if ARCH_BOARD_NTOSD_DM320 default "nucleo-144" if ARCH_BOARD_NUCLEO_144 default "nucleo-f072rb" if ARCH_BOARD_NUCLEO_F072RB @@ -2068,8 +2079,8 @@ endif if ARCH_BOARD_NE64BADGE source "configs/ne64badge/Kconfig" endif -if ARCH_BOARD_NRF52_PCA10040 -source "configs/nrf52-pca10040/Kconfig" +if ARCH_BOARD_NRF52_GENERIC +source "configs/nrf52-generic/Kconfig" endif if ARCH_BOARD_NTOSD_DM320 source "configs/ntosd-dm320/Kconfig" diff --git a/configs/README.txt b/configs/README.txt index 0745c7e1291..cdd40e436c4 100644 --- a/configs/README.txt +++ b/configs/README.txt @@ -410,9 +410,10 @@ configs/ne64badge STATUS: Under development. The port is code-complete but has not yet been fully tested. -configs/nrf52-pca10040 - NuttX port to the NRF PCA10040 board from Nordic Semiconductor - featuring the NRF52832 MCU. +configs/nrf52-generic + NuttX port to the a generic NRF52. Support is in place for the NRF + PCA10040 board from Nordic Semiconductor or for the Adafruit NRF52 + feather, both featuring the NRF52832 MCU. configs/ntosd-dm320 This port uses the Neuros OSD v1.0 Dev Board with a GNU arm-nuttx-elf diff --git a/configs/nrf52-generic/Kconfig b/configs/nrf52-generic/Kconfig new file mode 100644 index 00000000000..afcb1e870eb --- /dev/null +++ b/configs/nrf52-generic/Kconfig @@ -0,0 +1,56 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_NRF52_GENERIC + +config NRF52_GENERIC_UART0_RX_PIN + int "Pin select for UART0 TXD" + default 23 + ---help--- + Pin select for UART0 TXD + +config NRF52_GENERIC_UART0_TX_PIN + int "Pin select for UART0 TXD" + default 24 + ---help--- + Pin select for UART0 TXD + +config NRF52_GENERIC_NUM_LEDS + int "Number of LEDs" + default 4 + ---help--- + Number of LEDs + +config NRF52_GENERIC_LED_ACTIVELOW + bool "Board LEDs are 'active low'" + default y + ---help--- + Board LEDs are 'active low' + +config NRF52_GENERIC_LED1_PIN + int "Pin select for LED 1" + default 17 + ---help--- + Pin select for LED 1 + +config NRF52_GENERIC_LED2_PIN + int "Pin select for LED 2" + default 18 + ---help--- + Pin select for LED 2 + +config NRF52_GENERIC_LED3_PIN + int "Pin select for LED 3" + default 19 + ---help--- + Pin select for LED 3 + +config NRF52_GENERIC_LED4_PIN + int "Pin select for LED 4" + default 20 + ---help--- + Pin select for LED 4 + +endif diff --git a/configs/nrf52-pca10040/README.txt b/configs/nrf52-generic/README.txt similarity index 65% rename from configs/nrf52-pca10040/README.txt rename to configs/nrf52-generic/README.txt index 83452680bd0..22ae73e45d9 100644 --- a/configs/nrf52-pca10040/README.txt +++ b/configs/nrf52-generic/README.txt @@ -1,35 +1,14 @@ README ====== -README for NuttX port to the NRF PCA10040 board from Nordic Semiconductor -featuring the NRF52832 MCU. +README for NuttX port to generic NRF52832 boards. Contents ======== - - PCA10040 development board - Status - - LED and Pushbuttons - - Serial Console + - PCA10040 development board - Configurations - - STATUS - -PCA10040 board -============== - - Memory Map - ---------- - - Block Start Length - Name Address - --------------------- ---------- ------ - FLASH 0x00000000 512K - RAM 0x20000000 64K - - Console - ------- - - The PCA10040 default console is the UART0. Status ====== @@ -40,10 +19,24 @@ Status are present and fully verified. This includes: SYSTICK system time, pin and GPIO configuration, and serial console support. -LED and Pushbuttons -=================== +PCA10040 board +============== - LEDS + Console + ------- + + The PCA10040 default console is the UART0. + + The PCA10040 does not have RS-232 drivers or serial connectors on board. + UART0, is available on P4 as follows: + + -------- ----- + Signal PIN + -------- ----- + UART0-TX P0.24 + UART0-RX P0.23 + + LEDs ---- The PCA10040 has 4 user-controllable LEDs @@ -55,47 +48,58 @@ LED and Pushbuttons A low output illuminates the LED. - If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows - for NuttX debug functionality (where NC means "No Change"). - - TBD! - - If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under - control of the application. The following interfaces are then available - for application control of the LEDs: - - void board_userled_initialize(void); - void board_userled(int led, bool ledon); - void board_userled_all(uint8_t ledset); - Pushbuttons ----------- To be provided -Serial Console -============== +Feather nRF52 board +=================== -The PCA10040 does not have RS-232 drivers or serial connectors on board. -UART0, is available on P4 as follows: + https://www.adafruit.com/product/3406 - -------- ----- - Signal PIN - -------- ----- - UART0-TX P0.24 - UART0-RX P0.23 + Console + ------- + The Feather nRF52 default console is the UART0. + + The Feather nRF52 have USB serial bridge chip on board and UART0 is + connected to micro USB connector through the bridge chip. + + LEDs + ---- + The Feather has 2 user-controllable LEDs + + LED MCU + LED1 PIN-17 + LED2 PIN-19 + + A high output illuminates the LED. + + Pushbuttons + ----------- + The Feather nRF52 does not have user-controllable buttons. The reset button + on the board is connected to nRF52832 reset pin directly. + +Memory Map +========== + + Block Start Length + Name Address + --------------------- ---------- ------ + FLASH 0x00000000 512K + RAM 0x20000000 64K Configurations ============== -Each PCA10040 configuration is maintained in a sub-directory and can be selected -as follow: +Each configuration is maintained in a sub-directory and can be selected as +follow: - tools/configure.sh nrf52-pca10040/ + tools/configure.sh nrf52-generic/ Where is one of the following: - nsh: - ---- + -nsh: + ----------- This configuration is the NuttShell (NSH) example at examples/nsh/. NOTES: @@ -109,8 +113,23 @@ Where is one of the following: b. Execute 'make menuconfig' in nuttx/ in order to start the reconfiguration process. - wdog: - ---- - + -wdog: + ------------ This configuration is a simple NSH-based test of the nRF52 watchdog timer driver using the test at apps/examples/watchdog. + + CONFIG_ARCH_LEDS + ---------------- + If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows + for NuttX debug functionality (where NC means "No Change"). + + TBD! + + If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + control of the application. The following interfaces are then available + for application control of the LEDs: + + void board_userled_initialize(void); + void board_userled(int led, bool ledon); + void board_userled_all(uint8_t ledset); + diff --git a/configs/nrf52-generic/feather-nsh/defconfig b/configs/nrf52-generic/feather-nsh/defconfig new file mode 100644 index 00000000000..e7ba14bdfd0 --- /dev/null +++ b/configs/nrf52-generic/feather-nsh/defconfig @@ -0,0 +1,47 @@ +# 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-generic" +CONFIG_ARCH_BOARD_NRF52_GENERIC=y +CONFIG_ARCH_CHIP_NRF52832=y +CONFIG_ARCH_CHIP_NRF52=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MM_REGIONS=2 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NRF52_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=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_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_NRF52_GENERIC_UART0_RX_PIN=8 +CONFIG_NRF52_GENERIC_UART0_TX_PIN=6 +CONFIG_NRF52_GENERIC_NUM_LEDS=2 +# CONFIG_NRF52_GENERIC_LED_ACTIVELOW is not set +CONFIG_NRF52_GENERIC_LED1_PIN=17 +CONFIG_NRF52_GENERIC_LED2_PIN=19 +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_WDOG_INTRESERVE=0 diff --git a/configs/nrf52-generic/feather-userleds/defconfig b/configs/nrf52-generic/feather-userleds/defconfig new file mode 100644 index 00000000000..f27346fa738 --- /dev/null +++ b/configs/nrf52-generic/feather-userleds/defconfig @@ -0,0 +1,52 @@ +# CONFIG_ARCH_FPU is not set +# CONFIG_ARCH_LEDS is not set +# CONFIG_NRF52_GENERIC_LED_ACTIVELOW is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf52-generic" +CONFIG_ARCH_BOARD_NRF52_GENERIC=y +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_EXAMPLES_LEDS=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MM_REGIONS=2 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NRF52_GENERIC_LED2_PIN=19 +CONFIG_NRF52_GENERIC_NUM_LEDS=2 +CONFIG_NRF52_GENERIC_UART0_RX_PIN=8 +CONFIG_NRF52_GENERIC_UART0_TX_PIN=6 +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_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=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_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_USERLED=y +CONFIG_USERLED_LOWER=y +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_WDOG_INTRESERVE=0 diff --git a/configs/nrf52-pca10040/include/board.h b/configs/nrf52-generic/include/board.h similarity index 92% rename from configs/nrf52-pca10040/include/board.h rename to configs/nrf52-generic/include/board.h index b5e85837897..84518e337b2 100644 --- a/configs/nrf52-pca10040/include/board.h +++ b/configs/nrf52-generic/include/board.h @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/nrf52-pca10040/include/board.h + * configs/nrf52_generic/include/board.h * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef _CONFIGS_NRF52_PCA10040_INCLUDE_BOARD_H -#define _CONFIGS_NRF52_PCA10040_INCLUDE_BOARD_H +#ifndef _CONFIGS_NRF52_GENERIC_INCLUDE_BOARD_H +#define _CONFIGS_NRF52_GENERIC_INCLUDE_BOARD_H /**************************************************************************** * Included Files @@ -66,7 +66,7 @@ #define BOARD_LED2 1 #define BOARD_LED3 2 #define BOARD_LED4 3 -#define BOARD_NLEDS 4 +#define BOARD_NLEDS CONFIG_NRF52_GENERIC_NUM_LEDS /* LED bits for use with board_userled_all() */ @@ -118,7 +118,7 @@ * driver can set up the UART for the serial console properly. */ -#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PIN23) -#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN24) +#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PIN(CONFIG_NRF52_GENERIC_UART0_RX_PIN)) +#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_UART0_TX_PIN)) -#endif /* _CONFIGS_NRF52_PCA10040_INCLUDE_BOARD_H */ +#endif /* _CONFIGS_NRF52_GENERIC_INCLUDE_BOARD_H */ diff --git a/configs/nrf52-pca10040/nsh/defconfig b/configs/nrf52-generic/pca10040-nsh/defconfig similarity index 93% rename from configs/nrf52-pca10040/nsh/defconfig rename to configs/nrf52-generic/pca10040-nsh/defconfig index 269cacbbff2..8a959e545c4 100644 --- a/configs/nrf52-pca10040/nsh/defconfig +++ b/configs/nrf52-generic/pca10040-nsh/defconfig @@ -2,8 +2,8 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nrf52-pca10040" -CONFIG_ARCH_BOARD_NRF52_PCA10040=y +CONFIG_ARCH_BOARD="nrf52-generic" +CONFIG_ARCH_BOARD_NRF52_GENERIC=y CONFIG_ARCH_CHIP_NRF52832=y CONFIG_ARCH_CHIP_NRF52=y CONFIG_ARCH_STACKDUMP=y diff --git a/configs/nrf52-pca10040/wdog/defconfig b/configs/nrf52-generic/pca10040-wdog/defconfig similarity index 93% rename from configs/nrf52-pca10040/wdog/defconfig rename to configs/nrf52-generic/pca10040-wdog/defconfig index 1d9b4f64c4d..74556716dbb 100644 --- a/configs/nrf52-pca10040/wdog/defconfig +++ b/configs/nrf52-generic/pca10040-wdog/defconfig @@ -2,8 +2,8 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nrf52-pca10040" -CONFIG_ARCH_BOARD_NRF52_PCA10040=y +CONFIG_ARCH_BOARD="nrf52-generic" +CONFIG_ARCH_BOARD_NRF52_GENERIC=y CONFIG_ARCH_CHIP_NRF52832=y CONFIG_ARCH_CHIP_NRF52=y CONFIG_ARCH_STACKDUMP=y diff --git a/configs/nrf52-pca10040/scripts/Make.defs b/configs/nrf52-generic/scripts/Make.defs similarity index 99% rename from configs/nrf52-pca10040/scripts/Make.defs rename to configs/nrf52-generic/scripts/Make.defs index 458e6b774ed..2dc353a236f 100644 --- a/configs/nrf52-pca10040/scripts/Make.defs +++ b/configs/nrf52-generic/scripts/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# configs/nrf52-pca10040/scripts/Make.defs +# configs/nrf52-generic/scripts/Make.defs # # Copyright (C) 2014, 2017, 2018 Gregory Nutt. All rights reserved. # Author: Gregory Nutt diff --git a/configs/nrf52-pca10040/scripts/flash_config.ld b/configs/nrf52-generic/scripts/flash_config.ld similarity index 98% rename from configs/nrf52-pca10040/scripts/flash_config.ld rename to configs/nrf52-generic/scripts/flash_config.ld index 288e3e417ad..1dbf47b89dd 100644 --- a/configs/nrf52-pca10040/scripts/flash_config.ld +++ b/configs/nrf52-generic/scripts/flash_config.ld @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/nrf52-pca10040/scripts/flash_config.ld + * configs/nrf52-generic/scripts/flash_config.ld * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg diff --git a/configs/nrf52-pca10040/src/.gitignore b/configs/nrf52-generic/src/.gitignore similarity index 100% rename from configs/nrf52-pca10040/src/.gitignore rename to configs/nrf52-generic/src/.gitignore diff --git a/configs/nrf52-pca10040/src/Makefile b/configs/nrf52-generic/src/Makefile similarity index 98% rename from configs/nrf52-pca10040/src/Makefile rename to configs/nrf52-generic/src/Makefile index 0a75a08de30..5816c990729 100644 --- a/configs/nrf52-pca10040/src/Makefile +++ b/configs/nrf52-generic/src/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# configs/nrf52-pca10040/src/Makefile +# configs/nrf52-generic/src/Makefile # # Copyright (C) 2018 Gregory Nutt. All rights reserved. # Author: Janne Rosberg diff --git a/configs/nrf52-pca10040/src/nrf52-pca10040.h b/configs/nrf52-generic/src/nrf52-generic.h similarity index 82% rename from configs/nrf52-pca10040/src/nrf52-pca10040.h rename to configs/nrf52-generic/src/nrf52-generic.h index 3a37565311c..8924756e378 100644 --- a/configs/nrf52-pca10040/src/nrf52-pca10040.h +++ b/configs/nrf52-generic/src/nrf52-generic.h @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/nrf52-pca10040/src/lpc4357-evb.h + * configs/nrf52-generic/src/nrf52-generic.h * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef _CONFIGS_NRF52PCA10040_SRC_NRF52PCA10040_H -#define _CONFIGS_NRF52PCA10040_SRC_NRF52PCA10040_H +#ifndef _CONFIGS_NRF52GENERIC_SRC_NRF52GENERIC_H +#define _CONFIGS_NRF52GENERIC_SRC_NRF52GENERIC_H /**************************************************************************** * Included Files @@ -50,27 +50,12 @@ ****************************************************************************/ /* LED definitions **********************************************************/ -/* The PCA10040 has 4 user-controllable LEDs - * - * ---- ------- ------------- - * LED SIGNAL MCU - * ---- ------- ------------- - * LED1 GPIO 17 - * LED2 GPIO 18 - * LED3 GPIO 19 - * LED4 GPIO 20 - * ---- ------- ------------- - * - * A low output illuminates the LED. - * - */ - /* Definitions to configure LED GPIO as outputs */ -#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN17) -#define GPIO_LED2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN18) -#define GPIO_LED3 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN19) -#define GPIO_LED4 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN20) +#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_LED1_PIN)) +#define GPIO_LED2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_LED2_PIN)) +#define GPIO_LED3 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_LED3_PIN)) +#define GPIO_LED4 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_LED4_PIN)) /* Button definitions *******************************************************/ /* Board supports four buttons. */ @@ -111,4 +96,4 @@ int nrf52_bringup(void); #endif /* __ASSEMBLY__ */ -#endif /* _CONFIGS_NRF52PCA10040_SRC_NRF52PCA10040_H */ +#endif /* _CONFIGS_NRF52GENERIC_SRC_NRF52GENERIC_H */ diff --git a/configs/nrf52-pca10040/src/nrf52_appinit.c b/configs/nrf52-generic/src/nrf52_appinit.c similarity index 98% rename from configs/nrf52-pca10040/src/nrf52_appinit.c rename to configs/nrf52-generic/src/nrf52_appinit.c index 503040655d0..6cd61207feb 100644 --- a/configs/nrf52-pca10040/src/nrf52_appinit.c +++ b/configs/nrf52-generic/src/nrf52_appinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * config/nrf52-pca10040/src/nrf52_appinit.c + * config/nrf52-generic/src/nrf52_appinit.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg @@ -46,7 +46,7 @@ #include #include "chip.h" -#include "nrf52-pca10040.h" +#include "nrf52-generic.h" /**************************************************************************** * Public Functions diff --git a/configs/nrf52-pca10040/src/nrf52_autoleds.c b/configs/nrf52-generic/src/nrf52_autoleds.c similarity index 82% rename from configs/nrf52-pca10040/src/nrf52_autoleds.c rename to configs/nrf52-generic/src/nrf52_autoleds.c index 3ad096d41ab..d5e9a2fdfc7 100644 --- a/configs/nrf52-pca10040/src/nrf52_autoleds.c +++ b/configs/nrf52-generic/src/nrf52_autoleds.c @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/nrf52-pca10040/src/lpc43_autoleds.c + * configs/nrf52-generic/src/lpc43_autoleds.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -61,10 +61,36 @@ #include "up_arch.h" #include "up_internal.h" -#include "nrf52-pca10040.h" +#include "nrf52-generic.h" #ifdef CONFIG_ARCH_LEDS +#ifdef CONFIG_NRF52_GENERIC_LED_ACTIVELOW +#define LED_ON 0 +#define LED_OFF 1 +#else +#define LED_ON 1 +#define LED_OFF 0 +#endif + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +#if 2 < BOARD_NLEDS + GPIO_LED3, +#endif +#if 3 < BOARD_NLEDS + GPIO_LED4, +#endif +}; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -93,14 +119,16 @@ static void led_dumppins(FAR const char *msg) void board_autoled_initialize(void) { + int i; + /* Configure LED pin as a GPIO outputs */ led_dumppins("board_autoled_initialize() Entry)"); - nrf52_gpio_config(GPIO_LED1); - nrf52_gpio_config(GPIO_LED2); - nrf52_gpio_config(GPIO_LED3); - nrf52_gpio_config(GPIO_LED4); + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_config(g_ledcfg[i]); + } led_dumppins("board_autoled_initialize() Exit"); } @@ -111,24 +139,9 @@ void board_autoled_initialize(void) void board_autoled_on(int led) { - switch (led) + if ((unsigned)led < BOARD_NLEDS) { - default: - case 0: - nrf52_gpio_write(GPIO_LED1, 0); - break; - - case 1: - nrf52_gpio_write(GPIO_LED2, 0); - break; - - case 2: - nrf52_gpio_write(GPIO_LED3, 0); - break; - - case 3: - nrf52_gpio_write(GPIO_LED4, 0); - break; + nrf52_gpio_write(g_ledcfg[led], LED_ON); } } @@ -138,24 +151,9 @@ void board_autoled_on(int led) void board_autoled_off(int led) { - switch (led) + if ((unsigned)led < BOARD_NLEDS) { - default: - case 0: - nrf52_gpio_write(GPIO_LED1, 1); - break; - - case 1: - nrf52_gpio_write(GPIO_LED2, 1); - break; - - case 2: - nrf52_gpio_write(GPIO_LED3, 1); - break; - - case 3: - nrf52_gpio_write(GPIO_LED4, 1); - break; + nrf52_gpio_write(g_ledcfg[led], LED_OFF); } } diff --git a/configs/nrf52-pca10040/src/nrf52_boot.c b/configs/nrf52-generic/src/nrf52_boot.c similarity index 98% rename from configs/nrf52-pca10040/src/nrf52_boot.c rename to configs/nrf52-generic/src/nrf52_boot.c index b6cd58b22d6..955ec3ac819 100644 --- a/configs/nrf52-pca10040/src/nrf52_boot.c +++ b/configs/nrf52-generic/src/nrf52_boot.c @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/nrf52-pca10040/src/lpc43_boot.c + * configs/nrf52-generic/src/lpc43_boot.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -47,7 +47,7 @@ #include "up_arch.h" #include "up_internal.h" -#include "nrf52-pca10040.h" +#include "nrf52-generic.h" /**************************************************************************** * Public Functions diff --git a/configs/nrf52-pca10040/src/nrf52_bringup.c b/configs/nrf52-generic/src/nrf52_bringup.c similarity index 88% rename from configs/nrf52-pca10040/src/nrf52_bringup.c rename to configs/nrf52-generic/src/nrf52_bringup.c index 65d5b5f3179..293830ed198 100644 --- a/configs/nrf52-pca10040/src/nrf52_bringup.c +++ b/configs/nrf52-generic/src/nrf52_bringup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * config/nrf52-pca10040/src/nrf53_bringup.c + * config/nrf52-generic/src/nrf53_bringup.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -42,7 +42,13 @@ #include #include -#include "nrf52_wdt.h" +#ifdef CONFIG_NRF52_WDT +# include "nrf52_wdt.h" +#endif + +#ifdef CONFIG_USERLED +# include +#endif /**************************************************************************** * Public Functions @@ -76,6 +82,16 @@ int nrf52_bringup(void) } #endif +#ifdef CONFIG_USERLED + /* Register the LED driver */ + + ret = userled_lower_initialize(CONFIG_EXAMPLES_LEDS_DEVPATH); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + } +#endif + UNUSED(ret); return OK; } diff --git a/configs/nrf52-pca10040/src/nrf52_buttons.c b/configs/nrf52-generic/src/nrf52_buttons.c similarity index 97% rename from configs/nrf52-pca10040/src/nrf52_buttons.c rename to configs/nrf52-generic/src/nrf52_buttons.c index fca3a450697..c0c2845e03b 100644 --- a/configs/nrf52-pca10040/src/nrf52_buttons.c +++ b/configs/nrf52-generic/src/nrf52_buttons.c @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/nrf52-pca10400/src/nrf52_buttons.c + * configs/nrf52-generic/src/nrf52_buttons.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg @@ -48,7 +48,7 @@ #include "nrf52_gpio.h" -#include "nrf52-pca10040.h" +#include "nrf52-generic.h" #ifdef CONFIG_ARCH_BUTTONS @@ -56,7 +56,7 @@ * Private Data ****************************************************************************/ -/* Pin configuration for each PCA10400 button. This array is indexed by +/* Pin configuration for each PCA10040 button. This array is indexed by * the BUTTON_* definitions in board.h */ diff --git a/configs/nrf52-pca10040/src/nrf52_userleds.c b/configs/nrf52-generic/src/nrf52_userleds.c similarity index 83% rename from configs/nrf52-pca10040/src/nrf52_userleds.c rename to configs/nrf52-generic/src/nrf52_userleds.c index 6ac5db8f3f3..9943ad55c7a 100644 --- a/configs/nrf52-pca10040/src/nrf52_userleds.c +++ b/configs/nrf52-generic/src/nrf52_userleds.c @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/nrf52-pca10040/src/nrf52_userleds.c + * configs/nrf52-generic/src/nrf52_userleds.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg @@ -49,7 +49,7 @@ #include "up_arch.h" #include "up_internal.h" -#include "nrf52-pca10040.h" +#include "nrf52-generic.h" #ifndef CONFIG_ARCH_LEDS @@ -67,6 +67,32 @@ * void board_userled_all(uint8_t ledset); */ +#ifdef CONFIG_NRF52_GENERIC_LED_ACTIVELOW +#define LED_ON 0 +#define LED_OFF 1 +#else +#define LED_ON 1 +#define LED_OFF 0 +#endif + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +#if 2 < BOARD_NLEDS + GPIO_LED3, +#endif +#if 3 < BOARD_NLEDS + GPIO_LED4, +#endif +}; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -95,16 +121,18 @@ static void led_dumppins(FAR const char *msg) void board_userled_initialize(void) { + int i; + /* Configure LED pin as a GPIO outputs */ led_dumppins("board_userled_initialize() Entry)"); /* Configure GPIO as an outputs */ - nrf52_gpio_config(GPIO_LED1); - nrf52_gpio_config(GPIO_LED2); - nrf52_gpio_config(GPIO_LED3); - nrf52_gpio_config(GPIO_LED4); + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_config(g_ledcfg[i]); + } led_dumppins("board_userled_initialize() Exit"); } @@ -115,9 +143,9 @@ void board_userled_initialize(void) void board_userled(int led, bool ledon) { - if (led == BOARD_LED1) + if ((unsigned)led < BOARD_NLEDS) { - nrf52_gpio_write(GPIO_LED1, !ledon); + nrf52_gpio_write(g_ledcfg[led], ledon ? LED_ON : LED_OFF); } } @@ -127,10 +155,14 @@ void board_userled(int led, bool ledon) void board_userled_all(uint8_t ledset) { - nrf52_gpio_write(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0); - nrf52_gpio_write(GPIO_LED2, (ledset & BOARD_LED2_BIT) == 0); - nrf52_gpio_write(GPIO_LED3, (ledset & BOARD_LED3_BIT) == 0); - nrf52_gpio_write(GPIO_LED4, (ledset & BOARD_LED4_BIT) == 0); + int i; + + /* Configure LED1-8 GPIOs for output */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_write(g_ledcfg[i], (ledset & (1 << i)) ? LED_ON : LED_OFF); + } } #endif /* !CONFIG_ARCH_LEDS */ diff --git a/configs/nrf52-pca10040/Kconfig b/configs/nrf52-pca10040/Kconfig deleted file mode 100644 index 6ad461321a3..00000000000 --- a/configs/nrf52-pca10040/Kconfig +++ /dev/null @@ -1,8 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -if ARCH_BOARD_NRF52_PCA10040 - -endif