diff --git a/external/platform/nrf52/include/platform/nrf52xxx.h b/external/platform/nrf52/include/platform/nrf52xxx.h index 412ecef0..7a36e04d 100755 --- a/external/platform/nrf52/include/platform/nrf52xxx.h +++ b/external/platform/nrf52/include/platform/nrf52xxx.h @@ -54,7 +54,7 @@ #ifndef NRF52_H #define NRF52_H - +#include #ifdef __cplusplus extern "C" { #endif @@ -498,7 +498,7 @@ typedef struct { /*!< FICR Structure __I uint32_t DEVICEADDRTYPE; /*!< Device address type */ __I uint32_t DEVICEADDR[2]; /*!< Description collection[0]: Device address 0 */ __I uint32_t RESERVED3[21]; - FICR_INFO_Type INFO; /*!< Device info */ + FICR_INFO_Type DEVICEINFO; /*!< Device info */ __I uint32_t RESERVED4[185]; FICR_TEMP_Type TEMP; /*!< Registers storing factory TEMP module linearization coefficients */ __I uint32_t RESERVED5[2]; diff --git a/external/platform/nrf52/system_nrf52.c b/external/platform/nrf52/system_nrf52.c index 18c07547..d3ca8288 100755 --- a/external/platform/nrf52/system_nrf52.c +++ b/external/platform/nrf52/system_nrf52.c @@ -30,8 +30,8 @@ #include #include -#include "nrf.h" -#include "system_nrf52.h" +#include +#include /*lint ++flb "Enter library region" */ diff --git a/platform/nrf52xxx/gpio.c b/platform/nrf52xxx/gpio.c index a72b500a..55a6e2ee 100644 --- a/platform/nrf52xxx/gpio.c +++ b/platform/nrf52xxx/gpio.c @@ -34,7 +34,7 @@ int gpio_config(unsigned nr, unsigned flags) if (flags & GPIO_OUTPUT) { - NRF_GPIO->PIN_CNF[nr] = GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos | \ + NRF_P0->PIN_CNF[nr] = GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos | \ GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos | \ GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos | \ GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos; @@ -46,7 +46,7 @@ int gpio_config(unsigned nr, unsigned flags) } else { init = GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos; } - NRF_GPIO->PIN_CNF[nr] = GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos | \ + NRF_P0->PIN_CNF[nr] = GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos | \ GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos | \ init; } @@ -58,9 +58,9 @@ void gpio_set(unsigned nr, unsigned on) DEBUG_ASSERT(nr <= NRF_MAX_PIN_NUMBER); if (on > 0) { - NRF_GPIO->OUTSET = 1 << nr; + NRF_P0->OUTSET = 1 << nr; } else { - NRF_GPIO->OUTCLR = 1 << nr; + NRF_P0->OUTCLR = 1 << nr; } } @@ -68,7 +68,7 @@ int gpio_get(unsigned nr) { DEBUG_ASSERT( nr <= NRF_MAX_PIN_NUMBER ); - if ( NRF_GPIO->IN & ( 1 << nr) ) { + if ( NRF_P0->IN & ( 1 << nr) ) { return 1; } else { return 0; diff --git a/platform/nrf52xxx/include/platform/nrf51.h b/platform/nrf52xxx/include/platform/nrf52.h similarity index 100% rename from platform/nrf52xxx/include/platform/nrf51.h rename to platform/nrf52xxx/include/platform/nrf52.h diff --git a/platform/nrf52xxx/init.c b/platform/nrf52xxx/init.c index 30389601..c0a631e2 100644 --- a/platform/nrf52xxx/init.c +++ b/platform/nrf52xxx/init.c @@ -39,13 +39,10 @@ void platform_early_init(void) void platform_init(void) { - dprintf(SPEW, "Nordic nrf51xxx platform for lk...\n"); + dprintf(SPEW, "Nordic nrf52xxx platform for lk...\n"); dprintf(SPEW, "\tFlash: %d pages of %d bytes each (%dk bytes total)\n", \ NRF_FICR->CODESIZE, NRF_FICR->CODEPAGESIZE, \ (NRF_FICR->CODESIZE * NRF_FICR->CODEPAGESIZE)>>10); - dprintf(SPEW, "\tRAM: %d blocks of %d bytes each (%dk bytes total)\n", \ - NRF_FICR->NUMRAMBLOCK, NRF_FICR->SIZERAMBLOCKS, \ - (NRF_FICR->NUMRAMBLOCK * NRF_FICR->SIZERAMBLOCKS)>>10); dprintf(SPEW, "\tRadio MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", \ (NRF_FICR->DEVICEADDR[1] >> 8) & 0xFF, \ (NRF_FICR->DEVICEADDR[1]) & 0xFF, \ @@ -53,6 +50,4 @@ void platform_init(void) (NRF_FICR->DEVICEADDR[0] >> 16) & 0xFF, \ (NRF_FICR->DEVICEADDR[0] >> 8) & 0xFF, \ (NRF_FICR->DEVICEADDR[0] >> 0) & 0xFF); - dprintf(SPEW, "\tHWID: 0x%04x\n",NRF_FICR->CONFIGID & 0x0000ffff); - } diff --git a/platform/nrf52xxx/rules.mk b/platform/nrf52xxx/rules.mk index 053bf951..618c689a 100644 --- a/platform/nrf52xxx/rules.mk +++ b/platform/nrf52xxx/rules.mk @@ -10,27 +10,19 @@ MEMBASE := 0x20000000 ARCH := arm ARM_CPU := cortex-m4 -ifeq ($(NRF51_CHIP),nrf51822-qfaa) +ifeq ($(NRF52_CHIP),nrf52832-qfaa) GLOBAL_DEFINES += -MEMSIZE ?= 16384 +MEMSIZE ?= 65536 endif -ifeq ($(NRF51_CHIP),nrf51822-ceaa) -GLOBAL_DEFINES += -MEMSIZE ?= 16384 -endif -ifeq ($(NRF51_CHIP),nrf51822-qfab) -GLOBAL_DEFINES += -MEMSIZE ?= 16384 -endif -ifeq ($(NRF51_CHIP),nrf51822-cdab) -GLOBAL_DEFINES += -MEMSIZE ?= 16384 -endif -ifeq ($(NRF51_CHIP),nrf51822-qfac) +ifeq ($(NRF52_CHIP),nrf52832-qfab) GLOBAL_DEFINES += MEMSIZE ?= 32768 endif -ifeq ($(NRF51_CHIP),nrf51822-cfac) +ifeq ($(NRF52_CHIP),nrf52832-chaa) +GLOBAL_DEFINES += +MEMSIZE ?= 65536 +endif +ifeq ($(NRF52_CHIP),nrf52832-chab) GLOBAL_DEFINES += MEMSIZE ?= 32768 endif @@ -48,7 +40,6 @@ MODULE_SRCS += \ $(LOCAL_DIR)/gpio.c \ $(LOCAL_DIR)/timer.c \ - LINKER_SCRIPT += \ $(BUILDDIR)/system-twosegment.ld diff --git a/platform/nrf52xxx/uart.c b/platform/nrf52xxx/uart.c index 6e33044c..8e1f1d9d 100644 --- a/platform/nrf52xxx/uart.c +++ b/platform/nrf52xxx/uart.c @@ -59,7 +59,7 @@ void uart_init_early(void) NRF_UART0->BAUDRATE = UART_BAUDRATE_BAUDRATE_Baud115200 << UART_BAUDRATE_BAUDRATE_Pos; NRF_UART0->CONFIG = UART_CONFIG_HWFC_Disabled << UART_CONFIG_HWFC_Pos | \ UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos; - NVIC_DisableIRQ(UART0_IRQn); + NVIC_DisableIRQ(UARTE0_UART0_IRQn); NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos; NRF_UART0->TXD = 'E'; NRF_UART0->TASKS_STARTTX=1; @@ -79,7 +79,7 @@ void uart_init(void) #endif //ENABLE_UART0 } -void nrf52_UART0_IRQ(void) +void nrf52_UARTE0_UART0_IRQ(void) { // char c; arm_cm_irq_entry(); diff --git a/platform/nrf52xxx/vectab.c b/platform/nrf52xxx/vectab.c index 7bab19fa..4594b51b 100644 --- a/platform/nrf52xxx/vectab.c +++ b/platform/nrf52xxx/vectab.c @@ -40,69 +40,84 @@ void nrf52_##x(void) __WEAK_ALIAS("nrf52_dummy_irq"); DEFAULT_HANDLER(POWER_CLOCK_IRQ); DEFAULT_HANDLER(RADIO_IRQ); -DEFAULT_HANDLER(UART0_IRQ); -DEFAULT_HANDLER(SPI0_TWI0_IRQ); -DEFAULT_HANDLER(SPI1_TWI1_IRQ); - -DEFAULT_HANDLER(RESERVED_IRQ); +DEFAULT_HANDLER(UARTE0_UART0_IRQ); +DEFAULT_HANDLER(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQ); +DEFAULT_HANDLER(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQ); +DEFAULT_HANDLER(NFCT_IRQ); DEFAULT_HANDLER(GPIOTE_IRQ); -DEFAULT_HANDLER(ADC_IRQ); +DEFAULT_HANDLER(SAADC_IRQ); DEFAULT_HANDLER(TIMER0_IRQ); DEFAULT_HANDLER(TIMER1_IRQ); DEFAULT_HANDLER(TIMER2_IRQ); - DEFAULT_HANDLER(RTC0_IRQ); DEFAULT_HANDLER(TEMP_IRQ); DEFAULT_HANDLER(RNG_IRQ); DEFAULT_HANDLER(ECB_IRQ); DEFAULT_HANDLER(CCM_AAR_IRQ); - DEFAULT_HANDLER(WDT_IRQ); DEFAULT_HANDLER(RTC1_IRQ); DEFAULT_HANDLER(QDEC_IRQ); -DEFAULT_HANDLER(LPCOMP_IRQ); -DEFAULT_HANDLER(SWI0_IRQ); - -DEFAULT_HANDLER(SWI1_IRQ); -DEFAULT_HANDLER(SWI2_IRQ); -DEFAULT_HANDLER(SWI3_IRQ); -DEFAULT_HANDLER(SWI4_IRQ); -DEFAULT_HANDLER(SWI5_IRQ); +DEFAULT_HANDLER(COMP_LPCOMP_IRQ); +DEFAULT_HANDLER(SWI0_EGU0_IRQ); +DEFAULT_HANDLER(SWI1_EGU1_IRQ); +DEFAULT_HANDLER(SWI2_EGU2_IRQ); +DEFAULT_HANDLER(SWI3_EGU3_IRQ); +DEFAULT_HANDLER(SWI4_EGU4_IRQ); +DEFAULT_HANDLER(SWI5_EGU5_IRQ); +DEFAULT_HANDLER(TIMER3_IRQ); +DEFAULT_HANDLER(TIMER4_IRQ); +DEFAULT_HANDLER(PWM0_IRQ); +DEFAULT_HANDLER(PDM_IRQ); +DEFAULT_HANDLER(MWU_IRQ); +DEFAULT_HANDLER(PWM1_IRQ); +DEFAULT_HANDLER(PWM2_IRQ); +DEFAULT_HANDLER(SPIM2_SPIS2_SPI2_IRQ); +DEFAULT_HANDLER(RTC2_IRQ); +DEFAULT_HANDLER(I2S_IRQ); +DEFAULT_HANDLER(FPU_IRQ); -#define VECTAB_ENTRY(x) [x##n] = nrf51_##x +#define VECTAB_ENTRY(x) [x##n] = nrf52_##x /* appended to the end of the main vector table */ const void *const __SECTION(".text.boot.vectab2") vectab2[] = { VECTAB_ENTRY(POWER_CLOCK_IRQ), VECTAB_ENTRY(RADIO_IRQ), - VECTAB_ENTRY(UART0_IRQ), - VECTAB_ENTRY(SPI0_TWI0_IRQ), - VECTAB_ENTRY(SPI1_TWI1_IRQ), - VECTAB_ENTRY(RESERVED_IRQ), + VECTAB_ENTRY(UARTE0_UART0_IRQ), + VECTAB_ENTRY(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQ), + VECTAB_ENTRY(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQ), + VECTAB_ENTRY(NFCT_IRQ), VECTAB_ENTRY(GPIOTE_IRQ), - VECTAB_ENTRY(ADC_IRQ), + VECTAB_ENTRY(SAADC_IRQ), VECTAB_ENTRY(TIMER0_IRQ), VECTAB_ENTRY(TIMER1_IRQ), VECTAB_ENTRY(TIMER2_IRQ), - VECTAB_ENTRY(RTC0_IRQ), VECTAB_ENTRY(TEMP_IRQ), VECTAB_ENTRY(RNG_IRQ), VECTAB_ENTRY(ECB_IRQ), VECTAB_ENTRY(CCM_AAR_IRQ), - VECTAB_ENTRY(WDT_IRQ), VECTAB_ENTRY(RTC1_IRQ), VECTAB_ENTRY(QDEC_IRQ), - VECTAB_ENTRY(LPCOMP_IRQ), - VECTAB_ENTRY(SWI0_IRQ), - - VECTAB_ENTRY(SWI1_IRQ), - VECTAB_ENTRY(SWI2_IRQ), - VECTAB_ENTRY(SWI3_IRQ), - VECTAB_ENTRY(SWI4_IRQ), - VECTAB_ENTRY(SWI5_IRQ), + VECTAB_ENTRY(COMP_LPCOMP_IRQ), + VECTAB_ENTRY(SWI0_EGU0_IRQ), + VECTAB_ENTRY(SWI1_EGU1_IRQ), + VECTAB_ENTRY(SWI2_EGU2_IRQ), + VECTAB_ENTRY(SWI3_EGU3_IRQ), + VECTAB_ENTRY(SWI4_EGU4_IRQ), + VECTAB_ENTRY(SWI5_EGU5_IRQ), + VECTAB_ENTRY(TIMER3_IRQ), + VECTAB_ENTRY(TIMER4_IRQ), + VECTAB_ENTRY(PWM0_IRQ), + VECTAB_ENTRY(PDM_IRQ), + VECTAB_ENTRY(MWU_IRQ), + VECTAB_ENTRY(PWM1_IRQ), + VECTAB_ENTRY(PWM2_IRQ), + VECTAB_ENTRY(SPIM2_SPIS2_SPI2_IRQ), + VECTAB_ENTRY(RTC2_IRQ), + VECTAB_ENTRY(I2S_IRQ), + VECTAB_ENTRY(FPU_IRQ), }; diff --git a/project/nrf52-pca10040-test.mk b/project/nrf52-pca10040-test.mk new file mode 100644 index 00000000..e559f3c8 --- /dev/null +++ b/project/nrf52-pca10040-test.mk @@ -0,0 +1,8 @@ +MODULES += \ + app/shell \ + app/tests \ + + + + +include project/target/nrf-pca10040.mk diff --git a/project/target/nrf-pca10040.mk b/project/target/nrf-pca10040.mk new file mode 100644 index 00000000..d5aa5080 --- /dev/null +++ b/project/target/nrf-pca10040.mk @@ -0,0 +1,3 @@ +LOCAL_DIR := $(GET_LOCAL_DIR) + +TARGET := nrf-pca10040 \ No newline at end of file diff --git a/target/nrf-pca10040/include/target/debugconfig.h b/target/nrf-pca10040/include/target/debugconfig.h new file mode 100644 index 00000000..88ffe5fd --- /dev/null +++ b/target/nrf-pca10040/include/target/debugconfig.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012 Travis Geiselbrecht + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef __TARGET_DEBUGCONFIG_H +#define __TARGET_DEBUGCONFIG_H + +#define DEBUG_UART 1 + +#endif diff --git a/target/nrf-pca10040/include/target/gpioconfig.h b/target/nrf-pca10040/include/target/gpioconfig.h new file mode 100644 index 00000000..43522b81 --- /dev/null +++ b/target/nrf-pca10040/include/target/gpioconfig.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Travis Geiselbrecht + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef __TARGET_GPIOCONFIG_H +#define __TARGET_GPIOCONFIG_H + +#include + +#define GPIO_LED1 17 +#define GPIO_LED2 18 +#define GPIO_LED3 19 +#define GPIO_LED4 20 + +#define UART0_TX_PIN 6 +#define UART0_RX_PIN 8 + + + +#endif diff --git a/target/nrf-pca10040/init.c b/target/nrf-pca10040/init.c new file mode 100644 index 00000000..98d1b4ee --- /dev/null +++ b/target/nrf-pca10040/init.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012 Travis Geiselbrecht + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +void target_early_init(void) +{ + /* configure the usart1 pins */ + gpio_config(GPIO_LED1, GPIO_OUTPUT); + gpio_config(GPIO_LED2, GPIO_OUTPUT); + gpio_config(GPIO_LED3, GPIO_OUTPUT); + gpio_config(GPIO_LED4, GPIO_OUTPUT); + + gpio_set(GPIO_LED1,1); + gpio_set(GPIO_LED2,1); + gpio_set(GPIO_LED3,0); + gpio_set(GPIO_LED4,0); + + nrf52_debug_early_init(); +} + + +void target_init(void) +{ + nrf52_debug_init(); + dprintf(SPEW,"Target: PCA10040 DK...\n"); +} diff --git a/target/nrf-pca10040/rules.mk b/target/nrf-pca10040/rules.mk new file mode 100644 index 00000000..cc50489b --- /dev/null +++ b/target/nrf-pca10040/rules.mk @@ -0,0 +1,17 @@ +LOCAL_DIR := $(GET_LOCAL_DIR) + +MODULE := $(LOCAL_DIR) + +NRF52_CHIP := nrf52832-qfaa + +PLATFORM := nrf52xxx + +GLOBAL_DEFINES += \ + ENABLE_UART0=1 \ + + +MODULE_SRCS += \ + $(LOCAL_DIR)/init.c + +include make/module.mk +