From 0f68519f852a558ea7ef1ba1f081419597e90490 Mon Sep 17 00:00:00 2001 From: tkuyucu Date: Thu, 13 Mar 2014 10:59:09 +0100 Subject: [PATCH 1/5] Update after hex enabled firmware release Removed SystemInit write to FWID. Added DEVICE_ERROR_PATTERN for error signaling. Exception for NRF added to board.c to keep irqs enabled since timer irq is needed for the wait function. Button pin names changed from BUTTON0 to BUTTON1 and from BUTTON1 to BUTTON2. --- libraries/mbed/common/board.c | 2 ++ .../TARGET_NRF51822/system_nrf51822.c | 15 +-------------- .../hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h | 14 +++++++------- .../hal/TARGET_NORDIC/TARGET_NRF51822/device.h | 2 ++ .../hal/TARGET_NORDIC/TARGET_NRF51822/us_ticker.c | 5 +++-- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/libraries/mbed/common/board.c b/libraries/mbed/common/board.c index 2ba3c0aa40..e492d31754 100644 --- a/libraries/mbed/common/board.c +++ b/libraries/mbed/common/board.c @@ -19,7 +19,9 @@ WEAK void mbed_die(void); WEAK void mbed_die(void) { +#ifndef NRF51_H __disable_irq(); // dont allow interrupts to disturb the flash pattern +#endif #if (DEVICE_ERROR_RED == 1) gpio_t led_red; gpio_init(&led_red, LED_RED, PIN_OUTPUT); diff --git a/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_NRF51822/system_nrf51822.c b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_NRF51822/system_nrf51822.c index 900b1fda2b..d30ee8a0c0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_NRF51822/system_nrf51822.c +++ b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_NRF51822/system_nrf51822.c @@ -43,25 +43,12 @@ void SystemCoreClockUpdate(void) } void SystemInit(void) -{ - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){ - } - //write FWID (NRF_UICR->FWID is readonly) - *(uint32_t *)0x10001010 = 0xFFFF0049; - - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){ - } - - NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos); - while (NRF_NVMC->READY == NVMC_READY_READY_Busy){ - } +{ // Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required // to enable the use of peripherals" found at Product Anomaly document for your device found at // https://www.nordicsemi.com/. The side effect of executing these instructions in the devices // that do not need it is that the new peripherals in the second generation devices (LPCOMP for // example) will not be available. - if (is_manual_peripheral_setup_needed()){ *(uint32_t volatile *)0x40000504 = 0xC007FFDF; *(uint32_t volatile *)0x40006C18 = 0x00008000; diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h index 48c41c70bc..e021868fed 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h @@ -98,13 +98,13 @@ typedef enum { P0_29 = p29, P0_30 = p30, - LED1 = p18, - LED2 = p19, - LED3 = p18, - LED4 = p19, - - BUTTON0 = p16, - BUTTON1 = p17, + LED1 = p18, + LED2 = p19, + LED3 = p18, + LED4 = p19, + + BUTTON1 = p16, + BUTTON2 = p17, RX_PIN_NUMBER = p11, TX_PIN_NUMBER = p9, diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/device.h b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/device.h index ee7c664a67..9d5a5e2109 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/device.h +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/device.h @@ -50,6 +50,8 @@ #define DEVICE_STDIO_MESSAGES 0 +#define DEVICE_ERROR_PATTERN 1 + #include "objects.h" #endif diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/us_ticker.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/us_ticker.c index a67413d40b..b6b2551753 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/us_ticker.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/us_ticker.c @@ -28,8 +28,9 @@ volatile uint16_t timeStamp=0; #ifdef __cplusplus extern "C" { #endif -void TIMER1_IRQHandler(void){ - if ((US_TICKER_TIMER->EVENTS_COMPARE[1] != 0) && +void TIMER1_IRQHandler(void){ + + if ((US_TICKER_TIMER->EVENTS_COMPARE[1] != 0) && ((US_TICKER_TIMER->INTENSET & TIMER_INTENSET_COMPARE1_Msk) != 0)) { US_TICKER_TIMER->EVENTS_COMPARE[1] = 0; From b4844e50a2fd174f68bc7e8f1cb56148a45b45ec Mon Sep 17 00:00:00 2001 From: tkuyucu Date: Thu, 13 Mar 2014 11:11:30 +0100 Subject: [PATCH 2/5] Added missing #endif --- libraries/mbed/common/board.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/mbed/common/board.c b/libraries/mbed/common/board.c index b418c3739f..dfba788675 100644 --- a/libraries/mbed/common/board.c +++ b/libraries/mbed/common/board.c @@ -23,7 +23,8 @@ WEAK void mbed_die(void) { __disable_irq(); // dont allow interrupts to disturb the flash pattern #if (DEVICE_ERROR_RED == 1) gpio_t led_red; gpio_init_out(&led_red, LED_RED); - +#endif + #elif (DEVICE_ERROR_PATTERN == 1) gpio_t led_1; gpio_init_out(&led_1, LED1); gpio_t led_2; gpio_init_out(&led_2, LED2); From 4086fa09d9008ac05627da090d9b68b864da54c3 Mon Sep 17 00:00:00 2001 From: tkuyucu Date: Thu, 13 Mar 2014 12:28:59 +0100 Subject: [PATCH 3/5] merge with mbedmicro --- README.md | 31 +- libraries/USBDevice/USBDevice/USBEndpoints.h | 2 +- .../USBDevice/USBDevice/USBHAL_KL25Z.cpp | 62 +- libraries/USBHost/USBHost/USBHost.cpp | 395 ++-- libraries/USBHost/USBHost/USBHost.h | 12 + .../USBHost/USBHost3GModule/WANDongle.cpp | 9 +- libraries/mbed/api/DigitalIn.h | 11 +- libraries/mbed/api/DigitalInOut.h | 13 +- libraries/mbed/api/DigitalOut.h | 11 +- libraries/mbed/api/mbed.h | 2 +- libraries/mbed/common/InterruptIn.cpp | 2 +- libraries/mbed/common/board.c | 12 +- libraries/mbed/common/gpio.c | 56 + libraries/mbed/hal/gpio_api.h | 9 +- .../TARGET_LPC11U35_501/LPC11U35.sct | 20 + .../TARGET_LPC11U35_501/startup_LPC11xx.s | 325 ++++ .../TARGET_LPC11U35_501/LPC11U35.sct | 20 + .../TARGET_LPC11U35_501/startup_LPC11xx.s | 308 ++++ .../TARGET_NUCLEO_F030R8/stm32f0xx.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_adc.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_adc.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_can.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_can.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_cec.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_cec.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_comp.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_comp.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_conf.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_crc.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_crc.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_crs.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_crs.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_dac.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_dac.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_dma.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_dma.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_exti.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_exti.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_flash.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_flash.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_gpio.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_gpio.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_i2c.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_i2c.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_misc.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_misc.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_pwr.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_pwr.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_rcc.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_rcc.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_rtc.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_rtc.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_spi.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_spi.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_tim.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_tim.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_usart.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_usart.h | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.c | 32 +- .../TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.h | 32 +- .../TARGET_NUCLEO_F030R8/system_stm32f0xx.c | 32 +- .../TARGET_NUCLEO_F030R8/system_stm32f0xx.h | 32 +- .../TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s | 68 +- .../TOOLCHAIN_ARM_STD/startup_stm32f401xe.s | 68 +- .../TOOLCHAIN_IAR/startup_stm32f401xe.s | 4 +- .../TARGET_NUCLEO_F401RE/stm32f401xe.h | 16 +- .../TARGET_NUCLEO_F401RE/stm32f4xx.h | 10 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal.c | 52 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal.h | 40 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c | 9 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h | 16 +- .../stm32f4xx_hal_adc_ex.c | 4 +- .../stm32f4xx_hal_adc_ex.h | 6 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c | 11 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h | 14 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h | 6 +- .../stm32f4xx_hal_cortex.c | 4 +- .../stm32f4xx_hal_cortex.h | 6 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c | 7 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h | 8 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c | 11 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h | 14 +- .../stm32f4xx_hal_cryp_ex.c | 4 +- .../stm32f4xx_hal_cryp_ex.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c | 19 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h | 16 +- .../stm32f4xx_hal_dac_ex.c | 4 +- .../stm32f4xx_hal_dac_ex.h | 12 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c | 33 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h | 18 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h | 29 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c | 19 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h | 6 +- .../stm32f4xx_hal_dma2d.c | 19 +- .../stm32f4xx_hal_dma2d.h | 14 +- .../stm32f4xx_hal_dma_ex.c | 4 +- .../stm32f4xx_hal_dma_ex.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c | 17 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h | 16 +- .../stm32f4xx_hal_flash.c | 24 +- .../stm32f4xx_hal_flash.h | 10 +- .../stm32f4xx_hal_flash_ex.c | 4 +- .../stm32f4xx_hal_flash_ex.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h | 6 +- .../stm32f4xx_hal_gpio_ex.h | 10 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c | 9 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h | 14 +- .../stm32f4xx_hal_hash_ex.c | 4 +- .../stm32f4xx_hal_hash_ex.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c | 55 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h | 19 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c | 8 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h | 22 +- .../stm32f4xx_hal_i2c_ex.c | 4 +- .../stm32f4xx_hal_i2c_ex.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c | 26 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h | 14 +- .../stm32f4xx_hal_i2s_ex.c | 4 +- .../stm32f4xx_hal_i2s_ex.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c | 39 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h | 14 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c | 16 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h | 19 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c | 15 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h | 14 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c | 22 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h | 10 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c | 33 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h | 12 +- .../stm32f4xx_hal_pccard.c | 17 +- .../stm32f4xx_hal_pccard.h | 10 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c | 123 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h | 97 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h | 6 +- .../stm32f4xx_hal_pwr_ex.c | 4 +- .../stm32f4xx_hal_pwr_ex.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c | 27 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h | 18 +- .../stm32f4xx_hal_rcc_ex.c | 120 +- .../stm32f4xx_hal_rcc_ex.h | 6 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c | 15 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h | 12 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c | 35 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h | 10 +- .../stm32f4xx_hal_rtc_ex.c | 4 +- .../stm32f4xx_hal_rtc_ex.h | 14 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c | 90 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h | 14 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h | 20 +- .../stm32f4xx_hal_sdram.c | 21 +- .../stm32f4xx_hal_sdram.h | 14 +- .../stm32f4xx_hal_smartcard.c | 34 +- .../stm32f4xx_hal_smartcard.h | 14 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c | 61 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h | 12 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c | 11 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h | 12 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c | 36 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h | 16 +- .../stm32f4xx_hal_tim_ex.c | 9 +- .../stm32f4xx_hal_tim_ex.h | 8 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c | 59 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h | 18 +- .../stm32f4xx_hal_usart.c | 46 +- .../stm32f4xx_hal_usart.h | 20 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c | 7 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h | 10 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c | 18 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c | 8 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h | 4 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c | 170 +- .../TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h | 4 +- .../TARGET_NUCLEO_F401RE/system_stm32f4xx.c | 290 +-- .../TARGET_NUCLEO_F401RE/system_stm32f4xx.h | 4 +- .../TARGET_STM/TARGET_NUCLEO_L152RE/misc.c | 32 +- .../TARGET_STM/TARGET_NUCLEO_L152RE/misc.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_adc.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_adc.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_aes.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_aes.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_aes_util.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_comp.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_comp.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_conf.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_crc.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_crc.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_dac.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_dac.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_dma.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_dma.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_exti.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_exti.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_flash.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_flash.h | 32 +- .../stm32l1xx_flash_ramfunc.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_gpio.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_gpio.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_i2c.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_i2c.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_lcd.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_lcd.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_opamp.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_opamp.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_pwr.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_pwr.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_rcc.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_rcc.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_rtc.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_rtc.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_sdio.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_sdio.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_spi.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_spi.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_tim.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_tim.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_usart.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_usart.h | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.c | 32 +- .../TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.h | 32 +- .../TARGET_NUCLEO_L152RE/system_stm32l1xx.c | 32 +- .../TARGET_NUCLEO_L152RE/system_stm32l1xx.h | 32 +- .../TARGET_Freescale/TARGET_K20D5M/PinNames.h | 1 + .../TARGET_Freescale/TARGET_K20D5M/gpio_api.c | 12 +- .../TARGET_KLXX/TARGET_KL05Z/PinNames.h | 6 +- .../TARGET_KLXX/TARGET_KL05Z/gpio_irq_api.c | 4 +- .../TARGET_KLXX/TARGET_KL25Z/PeripheralPins.c | 2 +- .../TARGET_KLXX/TARGET_KL25Z/PinNames.h | 6 +- .../TARGET_KLXX/TARGET_KL25Z/gpio_irq_api.c | 4 +- .../TARGET_KLXX/TARGET_KL46Z/PeripheralPins.c | 2 +- .../TARGET_KLXX/TARGET_KL46Z/PinNames.h | 12 +- .../TARGET_KLXX/TARGET_KL46Z/gpio_irq_api.c | 4 +- .../TARGET_Freescale/TARGET_KLXX/gpio_api.c | 8 +- .../TARGET_NORDIC/TARGET_NRF51822/PinNames.h | 3 +- .../TARGET_NORDIC/TARGET_NRF51822/gpio_api.c | 8 +- .../TARGET_LPC11U24_301/PinNames.h | 3 +- .../TARGET_LPC11U24_401/PinNames.h | 26 +- .../TARGET_LPC11U35_401/PinNames.h | 3 +- .../TARGET_LPC11U35_501/PeripheralNames.h | 71 + .../TARGET_LPC11U35_501/PinNames.h | 176 ++ .../TARGET_LPC11U35_501/device.h | 59 + .../hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c | 8 +- .../TARGET_LPC11CXX/PinNames.h | 3 +- .../TARGET_LPC11XX/PinNames.h | 3 +- .../TARGET_LPC11XX_11CXX/gpio_api.c | 9 +- .../hal/TARGET_NXP/TARGET_LPC13XX/PinNames.h | 3 +- .../hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c | 8 +- .../TARGET_LPC15XX/PeripheralNames.h | 3 + .../hal/TARGET_NXP/TARGET_LPC15XX/PinNames.h | 3 +- .../TARGET_NXP/TARGET_LPC15XX/analogout_api.c | 73 + .../hal/TARGET_NXP/TARGET_LPC15XX/device.h | 4 +- .../hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c | 8 +- .../hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c | 108 +- .../hal/TARGET_NXP/TARGET_LPC15XX/objects.h | 9 + .../TARGET_NXP/TARGET_LPC15XX/pwmout_api.c | 173 ++ .../hal/TARGET_NXP/TARGET_LPC15XX/us_ticker.c | 71 +- .../TARGET_MBED_LPC1768/PinNames.h | 26 +- .../TARGET_UBLOX_C027/PinNames.h | 3 +- .../TARGET_UBLOX_C027/platform_init.c | 36 +- .../hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c | 8 +- .../TARGET_NXP/TARGET_LPC176X/serial_api.c | 13 +- .../hal/TARGET_NXP/TARGET_LPC23XX/PinNames.h | 3 +- .../hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c | 8 +- .../hal/TARGET_NXP/TARGET_LPC408X/PinNames.h | 3 +- .../hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c | 8 +- .../hal/TARGET_NXP/TARGET_LPC43XX/PinNames.h | 3 +- .../hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c | 8 +- .../TARGET_LPC81X/TARGET_LPC810/PinNames.h | 3 +- .../TARGET_LPC81X/TARGET_LPC812/PinNames.h | 3 +- .../hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c | 8 +- .../TARGET_NUCLEO_F030R8/PinNames.h | 198 +- .../TARGET_NUCLEO_F030R8/gpio_api.c | 10 +- .../TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c | 22 +- .../TARGET_NUCLEO_F103RB/PinNames.h | 189 +- .../TARGET_NUCLEO_F103RB/gpio_api.c | 10 +- .../TARGET_NUCLEO_F401RE/PeripheralNames.h | 9 +- .../TARGET_NUCLEO_F401RE/PinNames.h | 189 +- .../TARGET_NUCLEO_F401RE/gpio_api.c | 10 +- .../TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c | 19 + .../TARGET_NUCLEO_F401RE/serial_api.c | 14 +- .../TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c | 46 +- .../TARGET_NUCLEO_L152RE/PinNames.h | 189 +- .../TARGET_NUCLEO_L152RE/gpio_api.c | 10 +- .../TARGET_STM/TARGET_STM32F4XX/PinNames.h | 3 +- .../TARGET_STM/TARGET_STM32F4XX/gpio_api.c | 10 +- .../CellularModem/at/ATCommandsInterface.cpp | 18 +- .../CellularModem/link/LinkMonitor.cpp | 23 + .../cellular/CellularModem/link/LinkMonitor.h | 7 +- .../net/cellular/UbloxUSBModem/UbloxModem.cpp | 133 +- .../net/cellular/UbloxUSBModem/UbloxModem.h | 17 +- libraries/rtos/rtx/RTX_CM_lib.h | 14 +- libraries/rtos/rtx/RTX_Conf_CM.c | 6 +- libraries/tests/mbed/echo/main.cpp | 12 +- libraries/tests/mbed/env/test_env.cpp | 6 +- libraries/tests/mbed/interruptin/main.cpp | 4 + libraries/tests/mbed/ticker_2/main.cpp | 6 +- libraries/tests/mbed/time_us/main.cpp | 6 +- libraries/tests/mbed/timeout/main.cpp | 4 +- .../BLE_API_Native/GapAdvertisingData.cpp | 240 +++ .../BLE_API_Native/GapAdvertisingData.h | 212 +++ .../BLE_API_Native/GapAdvertisingParams.cpp | 168 ++ .../BLE_API_Native/GapAdvertisingParams.h | 89 + .../BLE_API_Native/GattCharacteristic.cpp | 65 + .../BLE_API_Native/GattCharacteristic.h | 318 ++++ .../BLE_API_Native/GattService.cpp | 111 ++ .../BLE_API_Native/GattService.h | 70 + .../BLE_API_Native/UUID.cpp | 194 ++ .../BLE_API_Native/UUID.h | 47 + .../BLE_API_Native/blecommon.h | 48 + .../BLE_API_Native/hw/BLEDevice.h | 41 + .../BLE_API_Native/hw/Gap.h | 76 + .../BLE_API_Native/hw/GapEvents.h | 71 + .../BLE_API_Native/hw/GattServer.h | 76 + .../BLE_API_Native/hw/GattServerEvents.h | 91 + .../BLE_API_Native/hw/nRF51822n/btle/btle.cpp | 220 +++ .../BLE_API_Native/hw/nRF51822n/btle/btle.h | 35 + .../hw/nRF51822n/btle/btle_advertising.cpp | 43 + .../hw/nRF51822n/btle/btle_advertising.h | 24 + .../hw/nRF51822n/btle/btle_gap.cpp | 90 + .../hw/nRF51822n/btle/btle_gap.h | 24 + .../nRF51822n/btle/custom/custom_helper.cpp | 163 ++ .../hw/nRF51822n/btle/custom/custom_helper.h | 38 + .../hw/nRF51822n/common/ansi_escape.h | 103 ++ .../hw/nRF51822n/common/assertion.h | 200 +++ .../hw/nRF51822n/common/binary.h | 96 + .../hw/nRF51822n/common/ble_error.h | 151 ++ .../hw/nRF51822n/common/common.h | 236 +++ .../hw/nRF51822n/common/compiler.h | 152 ++ .../BLE_API_Native/hw/nRF51822n/nRF51822n.cpp | 89 + .../BLE_API_Native/hw/nRF51822n/nRF51822n.h | 49 + .../BLE_API_Native/hw/nRF51822n/nRF51Gap.cpp | 234 +++ .../BLE_API_Native/hw/nRF51822n/nRF51Gap.h | 53 + .../hw/nRF51822n/nRF51GattServer.cpp | 231 +++ .../hw/nRF51822n/nRF51GattServer.h | 64 + .../nRF51822n/nordic/app_common/app_timer.cpp | 1130 ++++++++++++ .../hw/nRF51822n/nordic/app_common/crc16.cpp | 31 + .../nRF51822n/nordic/app_common/pstorage.cpp | 759 ++++++++ .../hw/nRF51822n/nordic/ble/ble_advdata.cpp | 624 +++++++ .../nordic/ble/ble_advdata_parser.cpp | 21 + .../hw/nRF51822n/nordic/ble/ble_bondmngr.cpp | 1594 +++++++++++++++++ .../nRF51822n/nordic/ble/ble_conn_params.cpp | 322 ++++ .../nordic/ble/ble_debug_assert_handler.cpp | 55 + .../hw/nRF51822n/nordic/ble/ble_error_log.cpp | 61 + .../ble/ble_services/ble_srv_common.cpp | 41 + .../hw/nRF51822n/nordic/ble_bondmngr_cfg.h | 35 + .../hw/nRF51822n/nordic/nordic_global.h | 11 + .../nordic/nrf-sdk/app_common/app_button.h | 174 ++ .../nordic/nrf-sdk/app_common/app_error.h | 78 + .../nordic/nrf-sdk/app_common/app_fifo.h | 84 + .../nordic/nrf-sdk/app_common/app_gpiote.h | 161 ++ .../nordic/nrf-sdk/app_common/app_scheduler.h | 135 ++ .../nordic/nrf-sdk/app_common/app_timer.h | 294 +++ .../nordic/nrf-sdk/app_common/app_uart.h | 285 +++ .../nordic/nrf-sdk/app_common/app_util.h | 308 ++++ .../nordic/nrf-sdk/app_common/crc16.h | 44 + .../nordic/nrf-sdk/app_common/hci_mem_pool.h | 133 ++ .../app_common/hci_mem_pool_internal.h | 32 + .../nordic/nrf-sdk/app_common/hci_slip.h | 130 ++ .../nordic/nrf-sdk/app_common/hci_transport.h | 221 +++ .../nordic/nrf-sdk/app_common/pstorage.h | 334 ++++ .../nordic/nrf-sdk/ble/ble_advdata.h | 114 ++ .../nordic/nrf-sdk/ble/ble_advdata_parser.h | 10 + .../nordic/nrf-sdk/ble/ble_bondmngr.h | 339 ++++ .../nordic/nrf-sdk/ble/ble_central_bondmngr.h | 26 + .../nordic/nrf-sdk/ble/ble_conn_params.h | 112 ++ .../nordic/nrf-sdk/ble/ble_date_time.h | 77 + .../nrf-sdk/ble/ble_debug_assert_handler.h | 49 + .../hw/nRF51822n/nordic/nrf-sdk/ble/ble_dtm.h | 142 ++ .../nordic/nrf-sdk/ble/ble_error_log.h | 70 + .../nRF51822n/nordic/nrf-sdk/ble/ble_flash.h | 143 ++ .../nRF51822n/nordic/nrf-sdk/ble/ble_racp.h | 98 + .../nrf-sdk/ble/ble_radio_notification.h | 46 + .../nordic/nrf-sdk/ble/ble_sensorsim.h | 66 + .../nrf-sdk/ble/ble_services/ble_srv_common.h | 235 +++ .../nrf-sdk/ble/rpc/ble_rpc_cmd_decoder.h | 81 + .../nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gap.h | 53 + .../ble/rpc/ble_rpc_cmd_decoder_gatts.h | 53 + .../nrf-sdk/ble/rpc/ble_rpc_cmd_encoder.h | 70 + .../nordic/nrf-sdk/ble/rpc/ble_rpc_defines.h | 55 + .../nrf-sdk/ble/rpc/ble_rpc_event_decoder.h | 50 + .../ble/rpc/ble_rpc_event_decoder_gap.h | 49 + .../ble/rpc/ble_rpc_event_decoder_gatts.h | 55 + .../nrf-sdk/ble/rpc/ble_rpc_event_encoder.h | 38 + .../ble/rpc/ble_rpc_event_encoder_gap.h | 41 + .../ble/rpc/ble_rpc_event_encoder_gatts.h | 41 + .../nrf-sdk/ble/rpc/ble_rpc_pkt_receiver.h | 35 + .../nRF51822n/nordic/nrf-sdk/nordic_common.h | 73 + .../hw/nRF51822n/nordic/nrf-sdk/nrf_assert.h | 59 + .../hw/nRF51822n/nordic/nrf-sdk/nrf_ecb.h | 67 + .../hw/nRF51822n/nordic/nrf-sdk/nrf_gpio.h | 411 +++++ .../hw/nRF51822n/nordic/nrf-sdk/nrf_nvmc.h | 91 + .../hw/nRF51822n/nordic/nrf-sdk/nrf_temp.h | 62 + .../hw/nRF51822n/nordic/nrf-sdk/s110/ble.h | 303 ++++ .../nRF51822n/nordic/nrf-sdk/s110/ble_err.h | 54 + .../nRF51822n/nordic/nrf-sdk/s110/ble_gap.h | 896 +++++++++ .../nRF51822n/nordic/nrf-sdk/s110/ble_gatt.h | 167 ++ .../nRF51822n/nordic/nrf-sdk/s110/ble_gattc.h | 396 ++++ .../nRF51822n/nordic/nrf-sdk/s110/ble_gatts.h | 548 ++++++ .../nRF51822n/nordic/nrf-sdk/s110/ble_hci.h | 96 + .../nRF51822n/nordic/nrf-sdk/s110/ble_l2cap.h | 136 ++ .../nordic/nrf-sdk/s110/ble_ranges.h | 72 + .../nRF51822n/nordic/nrf-sdk/s110/ble_types.h | 158 ++ .../nRF51822n/nordic/nrf-sdk/s110/nrf_error.h | 51 + .../nordic/nrf-sdk/s110/nrf_error_sdm.h | 33 + .../nordic/nrf-sdk/s110/nrf_error_soc.h | 49 + .../nRF51822n/nordic/nrf-sdk/s110/nrf_sdm.h | 164 ++ .../nRF51822n/nordic/nrf-sdk/s110/nrf_soc.h | 778 ++++++++ .../nRF51822n/nordic/nrf-sdk/s110/nrf_svc.h | 35 + .../nordic/nrf-sdk/s110/softdevice_assert.h | 47 + .../sd_common/ant_stack_handler_types.h | 70 + .../sd_common/ble_stack_handler_types.h | 67 + .../nrf-sdk/sd_common/softdevice_handler.h | 165 ++ .../nRF51822n/nordic/nrf-sdk/system_nrf51.h | 53 + .../hw/nRF51822n/nordic/pstorage_platform.h | 62 + .../nRF51822n/nordic/softdevice_handler.cpp | 313 ++++ .../hw/nRF51822n/projectconfig.h | 134 ++ .../BLE_Health_Thermometer_full/main.cpp | 218 +++ workspace_tools/build_release.py | 7 +- workspace_tools/buildbot/master.cfg | 406 +++++ workspace_tools/export/gcc_arm_lpc1114.tmpl | 46 + workspace_tools/export/gcc_arm_lpc11u24.tmpl | 46 + workspace_tools/export/gccarm.py | 2 +- workspace_tools/export/iar.py | 2 +- workspace_tools/export/uvision4.py | 4 +- workspace_tools/export_test.py | 3 +- workspace_tools/singletest.py | 452 +++++ workspace_tools/targets.py | 33 +- workspace_tools/tests.py | 5 + 448 files changed, 26429 insertions(+), 3398 deletions(-) create mode 100644 libraries/mbed/common/gpio.c create mode 100644 libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_MICRO/TARGET_LPC11U35_501/LPC11U35.sct create mode 100644 libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_MICRO/TARGET_LPC11U35_501/startup_LPC11xx.s create mode 100644 libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_STD/TARGET_LPC11U35_501/LPC11U35.sct create mode 100644 libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_STD/TARGET_LPC11U35_501/startup_LPC11xx.s create mode 100644 libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/PeripheralNames.h create mode 100644 libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/PinNames.h create mode 100644 libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/device.h create mode 100644 libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogout_api.c create mode 100644 libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingData.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingData.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingParams.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingParams.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattCharacteristic.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattCharacteristic.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattService.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattService.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/UUID.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/UUID.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/blecommon.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/BLEDevice.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/Gap.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GapEvents.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GattServer.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GattServerEvents.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_advertising.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_advertising.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_gap.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_gap.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/custom/custom_helper.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/custom/custom_helper.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/ansi_escape.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/assertion.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/binary.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/ble_error.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/common.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/compiler.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51822n.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51822n.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51Gap.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51Gap.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51GattServer.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51GattServer.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/app_timer.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/crc16.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/pstorage.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_advdata.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_advdata_parser.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_bondmngr.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_conn_params.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_debug_assert_handler.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_error_log.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_services/ble_srv_common.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble_bondmngr_cfg.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nordic_global.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_button.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_error.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_fifo.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_gpiote.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_scheduler.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_timer.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_uart.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_util.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/crc16.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool_internal.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_slip.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_transport.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/pstorage.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_advdata.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_advdata_parser.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_bondmngr.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_central_bondmngr.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_conn_params.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_date_time.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_debug_assert_handler.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_dtm.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_error_log.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_flash.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_racp.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_radio_notification.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_sensorsim.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_services/ble_srv_common.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gap.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gatts.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_encoder.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_defines.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gap.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gatts.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gap.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gatts.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_pkt_receiver.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nordic_common.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_assert.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_ecb.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_gpio.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_nvmc.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_temp.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_err.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gap.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gatt.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gattc.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gatts.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_hci.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_l2cap.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_ranges.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_types.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error_sdm.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error_soc.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_sdm.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_soc.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_svc.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/softdevice_assert.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/ant_stack_handler_types.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/ble_stack_handler_types.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/softdevice_handler.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/system_nrf51.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/pstorage_platform.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/softdevice_handler.cpp create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/projectconfig.h create mode 100644 libraries/tests/nordic/BLE_Health_Thermometer_full/main.cpp create mode 100644 workspace_tools/buildbot/master.cfg create mode 100644 workspace_tools/export/gcc_arm_lpc1114.tmpl create mode 100644 workspace_tools/export/gcc_arm_lpc11u24.tmpl create mode 100644 workspace_tools/singletest.py diff --git a/README.md b/README.md index bc30f04bb8..64046f1034 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -mbed SDK -======== +mbed SDK +======== [![Build Status](https://travis-ci.org/mbedmicro/mbed.png)](https://travis-ci.org/mbedmicro/mbed/builds) @@ -20,26 +20,28 @@ Documentation * [mbed library internals](http://mbed.org/handbook/mbed-library-internals) * [Adding a new target microcontroller](http://mbed.org/handbook/mbed-SDK-porting) -Supported Microcontrollers --------------------------- +Supported Microcontrollers and Boards +------------------------------------- NXP: -* [LPC1768](http://mbed.org/platforms/mbed-LPC1768/) (Cortex-M3) -* [LPC1768](http://mbed.org/platforms/u-blox-C027/) (Cortex-M3) -* [LPC11U24](http://mbed.org/platforms/mbed-LPC11U24/) (Cortex-M0) -* [LPC11U35](http://mbed.org/platforms/EA-LPC11U35/) (Cortex-M0) -* LPC2368 (ARM7TDMI-S) +* [mbed LPC1768](http://mbed.org/platforms/mbed-LPC1768/) (Cortex-M3) +* [u-blox C027 LPC1768](http://mbed.org/platforms/u-blox-C027/) (Cortex-M3) +* [mbed LPC11U24](http://mbed.org/platforms/mbed-LPC11U24/) (Cortex-M0) +* [EA LPC11U35](http://mbed.org/platforms/EA-LPC11U35/) (Cortex-M0) +* mbed LPC2368 (ARM7TDMI-S) * LPC810 (Cortex-M0+) * [LPC812](http://mbed.org/platforms/NXP-LPC800-MAX/) (Cortex-M0+) -* [LPC4088](http://mbed.org/platforms/EA-LPC4088/) (Cortex-M4) +* [EA LPC4088](http://mbed.org/platforms/EA-LPC4088/) (Cortex-M4) * LPC4330 (Cortex-M4 + Cortex-M0) * [LPC1347](http://mbed.org/platforms/DipCortex-M3/) (Cortex-M3) * [LPC1114](http://mbed.org/platforms/LPC1114FN28/) (Cortex-M0) * LPC11C24 (Cortex-M0) +* [LPC1549](https://mbed.org/platforms/LPCXpresso1549/) (Cortex-M3) Freescale: -* KL05Z (Cortex-M0+) -* [KL25Z](http://mbed.org/platforms/KL25Z/) (Cortex-M0+) -* [KL46Z](https://mbed.org/platforms/FRDM-KL46Z/) (Cortex-M0+) +* FRDM-K20D50M +* [FRDM-KL05Z](https://mbed.org/platforms/FRDM-KL05Z/) (Cortex-M0+) +* [FRDM-KL25Z](http://mbed.org/platforms/KL25Z/) (Cortex-M0+) +* [FRDM-KL46Z](https://mbed.org/platforms/FRDM-KL46Z/) (Cortex-M0+) STMicroelectronics: * [Nucleo-F103RB](https://mbed.org/platforms/ST-Nucleo-F103RB/) (Cortex-M3) @@ -48,6 +50,9 @@ STMicroelectronics: * [Nucleo-F401RE](https://mbed.org/platforms/ST-Nucleo-F401RE/) (Cortex-M4) * STM32F407 (Cortex-M4) +Nordic: +* [nRF51822-mKIT](https://mbed.org/platforms/Nordic-nRF51822/) (Cortex-M0) + Supported Toolchains and IDEs ----------------------------- * GCC ARM: [GNU Tools for ARM Embedded Processors](https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major) diff --git a/libraries/USBDevice/USBDevice/USBEndpoints.h b/libraries/USBDevice/USBDevice/USBEndpoints.h index 1c3409bd14..e36fc05a64 100644 --- a/libraries/USBDevice/USBDevice/USBEndpoints.h +++ b/libraries/USBDevice/USBDevice/USBEndpoints.h @@ -41,7 +41,7 @@ typedef enum { #include "USBEndpoints_LPC17_LPC23.h" #elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC1347) #include "USBEndpoints_LPC11U.h" -#elif defined(TARGET_KL25Z) +#elif defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M) #include "USBEndpoints_KL25Z.h" #elif defined (TARGET_STM32F4XX) #include "USBEndpoints_STM32F4.h" diff --git a/libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp b/libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp index 9afa2a980b..6a7a3bfb1d 100644 --- a/libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp +++ b/libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp @@ -16,7 +16,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if defined(TARGET_KL25Z) +#if defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M) #include "USBHAL.h" @@ -59,7 +59,7 @@ typedef struct BDT { uint8_t dummy; // RSVD: BD[8:15] uint16_t byte_count; // BD[16:32] uint32_t address; // Addr -} BDT; +} BDT; // there are: @@ -82,10 +82,10 @@ uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) { return 0; } -USBHAL::USBHAL(void) { +USBHAL::USBHAL(void) { // Disable IRQ NVIC_DisableIRQ(USB0_IRQn); - + // fill in callback array epCallback[0] = &USBHAL::EP1_OUT_callback; epCallback[1] = &USBHAL::EP1_IN_callback; @@ -117,11 +117,11 @@ USBHAL::USBHAL(void) { epCallback[27] = &USBHAL::EP14_IN_callback; epCallback[28] = &USBHAL::EP15_OUT_callback; epCallback[29] = &USBHAL::EP15_IN_callback; - - + + // choose usb src as PLL SIM->SOPT2 |= (SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL_MASK); - + // enable OTG clock SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK; @@ -129,12 +129,12 @@ USBHAL::USBHAL(void) { instance = this; NVIC_SetVector(USB0_IRQn, (uint32_t)&_usbisr); NVIC_EnableIRQ(USB0_IRQn); - + // USB Module Configuration // Reset USB Module USB0->USBTRC0 |= USB_USBTRC0_USBRESET_MASK; while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK); - + // Set BDT Base Register USB0->BDTPAGE1=(uint8_t)((uint32_t)bdt>>8); USB0->BDTPAGE2=(uint8_t)((uint32_t)bdt>>16); @@ -144,14 +144,14 @@ USBHAL::USBHAL(void) { USB0->ISTAT = 0xff; // USB Interrupt Enablers - USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK | - USB_INTEN_SOFTOKEN_MASK | + USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK | + USB_INTEN_SOFTOKEN_MASK | USB_INTEN_ERROREN_MASK | USB_INTEN_USBRSTEN_MASK; - - // Disable weak pull downs - USB0->USBCTRL &= ~(USB_USBCTRL_PDE_MASK | USB_USBCTRL_SUSP_MASK); - + + // Disable weak pull downs + USB0->USBCTRL &= ~(USB_USBCTRL_PDE_MASK | USB_USBCTRL_SUSP_MASK); + USB0->USBTRC0 |= 0x40; } @@ -296,9 +296,9 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_ uint32_t n, sz, idx, setup = 0; uint8_t not_iso; uint8_t * ep_buf; - + uint32_t log_endpoint = PHY_TO_LOG(endpoint); - + if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) { return EP_INVALID; } @@ -335,7 +335,7 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_ if (((Data1 >> endpoint) & 1) == ((bdt[idx].info >> 6) & 1)) { if (setup && (buffer[6] == 0)) // if no setup data stage, Data1 &= ~1UL; // set DATA0 - else + else Data1 ^= (1 << endpoint); } @@ -345,7 +345,7 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_ else { bdt[idx].info = BD_DTS_MASK | BD_OWN_MASK; } - + USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK; *bytesRead = sz; @@ -368,27 +368,27 @@ EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size) idx = EP_BDT_IDX(PHY_TO_LOG(endpoint), TX, 0); bdt[idx].byte_count = size; - - + + // non iso endpoint if (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPHSHK_MASK) { ep_buf = endpoint_buffer[idx]; } else { ep_buf = endpoint_buffer_iso[2]; } - + for (n = 0; n < size; n++) { ep_buf[n] = data[n]; } - + if ((Data1 >> endpoint) & 1) { bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK; } else { bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK | BD_DATA01_MASK; } - + Data1 ^= (1 << endpoint); - + return EP_PENDING; } @@ -429,7 +429,7 @@ void USBHAL::usbisr(void) { uint8_t istat = USB0->ISTAT; // reset interrupt - if (istat & USB_ISTAT_USBRST_MASK) { + if (istat & USB_ISTAT_USBRST_MASK) { // disable all endpt for(i = 0; i < 16; i++) { USB0->ENDPOINT[i].ENDPT = 0x00; @@ -457,11 +457,11 @@ void USBHAL::usbisr(void) { // SOF interrupt if (istat & USB_ISTAT_SOFTOK_MASK) { - USB0->ISTAT = USB_ISTAT_SOFTOK_MASK; + USB0->ISTAT = USB_ISTAT_SOFTOK_MASK; // SOF event, read frame number SOF(frameNumber()); } - + // stall interrupt if (istat & 1<<7) { if (USB0->ENDPOINT[0].ENDPT & USB_ENDPT_EPSTALL_MASK) @@ -483,7 +483,7 @@ void USBHAL::usbisr(void) { // EP0 SETUP event (SETUP data received) EP0setupCallback(); - + } else { // OUT packet if (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == OUT_TOKEN) { @@ -517,11 +517,11 @@ void USBHAL::usbisr(void) { USB0->ISTAT = USB_ISTAT_TOKDNE_MASK; } - + // sleep interrupt if (istat & 1<<4) { USB0->ISTAT |= USB_ISTAT_SLEEP_MASK; - } + } // error interrupt if (istat & USB_ISTAT_ERROR_MASK) { diff --git a/libraries/USBHost/USBHost/USBHost.cpp b/libraries/USBHost/USBHost/USBHost.cpp index c8ebb2c148..9da1e8edfa 100644 --- a/libraries/USBHost/USBHost/USBHost.cpp +++ b/libraries/USBHost/USBHost/USBHost.cpp @@ -79,133 +79,136 @@ void USBHost::usb_process() { too_many_hub = false; buf[4] = 0; - usb_mutex.lock(); + do + { + Lock lock(this); - for (i = 0; i < MAX_DEVICE_CONNECTED; i++) { - if (!deviceInUse[i]) { - USB_DBG_EVENT("new device connected: %p\r\n", &devices[i]); - devices[i].init(usb_msg->hub, usb_msg->port, usb_msg->lowSpeed); - deviceReset[i] = false; - deviceInited[i] = true; - break; - } - } - - if (i == MAX_DEVICE_CONNECTED) { - USB_ERR("Too many device connected!!\r\n"); - usb_mutex.unlock(); - continue; - } - - if (!controlEndpointAllocated) { - control = newEndpoint(CONTROL_ENDPOINT, OUT, 0x08, 0x00); - addEndpoint(NULL, 0, (USBEndpoint*)control); - controlEndpointAllocated = true; - } - -#if MAX_HUB_NB - if (usb_msg->hub_parent) - devices[i].setHubParent((USBHostHub *)(usb_msg->hub_parent)); -#endif - - for (j = 0; j < timeout_set_addr; j++) { - - resetDevice(&devices[i]); - - // set size of control endpoint - devices[i].setSizeControlEndpoint(8); - - devices[i].activeAddress(false); - - // get first 8 bit of device descriptor - // and check if we deal with a hub - USB_DBG("usb_thread read device descriptor on dev: %p\r\n", &devices[i]); - res = getDeviceDescriptor(&devices[i], buf, 8); - - if (res != USB_TYPE_OK) { - USB_ERR("usb_thread could not read dev descr"); - continue; - } - - // set size of control endpoint - devices[i].setSizeControlEndpoint(buf[7]); - - // second step: set an address to the device - res = setAddress(&devices[i], devices[i].getAddress()); - - if (res != USB_TYPE_OK) { - USB_ERR("SET ADDR FAILED"); - continue; - } - devices[i].activeAddress(true); - USB_DBG("Address of %p: %d", &devices[i], devices[i].getAddress()); - - // try to read again the device descriptor to check if the device - // answers to its new address - res = getDeviceDescriptor(&devices[i], buf, 8); - - if (res == USB_TYPE_OK) { - break; - } - - Thread::wait(100); - } - - USB_INFO("New device connected: %p [hub: %d - port: %d]", &devices[i], usb_msg->hub, usb_msg->port); - -#if MAX_HUB_NB - if (buf[4] == HUB_CLASS) { - for (k = 0; k < MAX_HUB_NB; k++) { - if (hub_in_use[k] == false) { - for (uint8_t j = 0; j < MAX_TRY_ENUMERATE_HUB; j++) { - if (hubs[k].connect(&devices[i])) { - devices[i].hub = &hubs[k]; - hub_in_use[k] = true; - break; - } - } - if (hub_in_use[k] == true) - break; - } - } - - if (k == MAX_HUB_NB) { - USB_ERR("Too many hubs connected!!\r\n"); - too_many_hub = true; - } - } - - if (usb_msg->hub_parent) - ((USBHostHub *)(usb_msg->hub_parent))->deviceConnected(&devices[i]); -#endif - - if ((i < MAX_DEVICE_CONNECTED) && !too_many_hub) { - deviceInUse[i] = true; - } - - usb_mutex.unlock(); + for (i = 0; i < MAX_DEVICE_CONNECTED; i++) { + if (!deviceInUse[i]) { + USB_DBG_EVENT("new device connected: %p\r\n", &devices[i]); + devices[i].init(usb_msg->hub, usb_msg->port, usb_msg->lowSpeed); + deviceReset[i] = false; + deviceInited[i] = true; + break; + } + } + + if (i == MAX_DEVICE_CONNECTED) { + USB_ERR("Too many device connected!!\r\n"); + continue; + } + + if (!controlEndpointAllocated) { + control = newEndpoint(CONTROL_ENDPOINT, OUT, 0x08, 0x00); + addEndpoint(NULL, 0, (USBEndpoint*)control); + controlEndpointAllocated = true; + } + + #if MAX_HUB_NB + if (usb_msg->hub_parent) + devices[i].setHubParent((USBHostHub *)(usb_msg->hub_parent)); + #endif + + for (j = 0; j < timeout_set_addr; j++) { + + resetDevice(&devices[i]); + + // set size of control endpoint + devices[i].setSizeControlEndpoint(8); + + devices[i].activeAddress(false); + + // get first 8 bit of device descriptor + // and check if we deal with a hub + USB_DBG("usb_thread read device descriptor on dev: %p\r\n", &devices[i]); + res = getDeviceDescriptor(&devices[i], buf, 8); + + if (res != USB_TYPE_OK) { + USB_ERR("usb_thread could not read dev descr"); + continue; + } + + // set size of control endpoint + devices[i].setSizeControlEndpoint(buf[7]); + + // second step: set an address to the device + res = setAddress(&devices[i], devices[i].getAddress()); + + if (res != USB_TYPE_OK) { + USB_ERR("SET ADDR FAILED"); + continue; + } + devices[i].activeAddress(true); + USB_DBG("Address of %p: %d", &devices[i], devices[i].getAddress()); + + // try to read again the device descriptor to check if the device + // answers to its new address + res = getDeviceDescriptor(&devices[i], buf, 8); + + if (res == USB_TYPE_OK) { + break; + } + + Thread::wait(100); + } + + USB_INFO("New device connected: %p [hub: %d - port: %d]", &devices[i], usb_msg->hub, usb_msg->port); + + #if MAX_HUB_NB + if (buf[4] == HUB_CLASS) { + for (k = 0; k < MAX_HUB_NB; k++) { + if (hub_in_use[k] == false) { + for (uint8_t j = 0; j < MAX_TRY_ENUMERATE_HUB; j++) { + if (hubs[k].connect(&devices[i])) { + devices[i].hub = &hubs[k]; + hub_in_use[k] = true; + break; + } + } + if (hub_in_use[k] == true) + break; + } + } + + if (k == MAX_HUB_NB) { + USB_ERR("Too many hubs connected!!\r\n"); + too_many_hub = true; + } + } + + if (usb_msg->hub_parent) + ((USBHostHub *)(usb_msg->hub_parent))->deviceConnected(&devices[i]); + #endif + + if ((i < MAX_DEVICE_CONNECTED) && !too_many_hub) { + deviceInUse[i] = true; + } + + } while(0); break; // a device has been disconnected case DEVICE_DISCONNECTED_EVENT: - usb_mutex.lock(); + do + { + Lock lock(this); - controlListState = disableList(CONTROL_ENDPOINT); - bulkListState = disableList(BULK_ENDPOINT); - interruptListState = disableList(INTERRUPT_ENDPOINT); - - idx = findDevice(usb_msg->hub, usb_msg->port, (USBHostHub *)(usb_msg->hub_parent)); - if (idx != -1) { - freeDevice((USBDeviceConnected*)&devices[idx]); - } + controlListState = disableList(CONTROL_ENDPOINT); + bulkListState = disableList(BULK_ENDPOINT); + interruptListState = disableList(INTERRUPT_ENDPOINT); + + idx = findDevice(usb_msg->hub, usb_msg->port, (USBHostHub *)(usb_msg->hub_parent)); + if (idx != -1) { + freeDevice((USBDeviceConnected*)&devices[idx]); + } + + if (controlListState) enableList(CONTROL_ENDPOINT); + if (bulkListState) enableList(BULK_ENDPOINT); + if (interruptListState) enableList(INTERRUPT_ENDPOINT); - if (controlListState) enableList(CONTROL_ENDPOINT); - if (bulkListState) enableList(BULK_ENDPOINT); - if (interruptListState) enableList(INTERRUPT_ENDPOINT); - - usb_mutex.unlock(); + } while(0); break; @@ -278,6 +281,15 @@ USBHost::USBHost() : usbThread(USBHost::usb_process_static, (void *)this, osPrio #endif } +USBHost::Lock::Lock(USBHost* pHost) : m_pHost(pHost) +{ + m_pHost->usb_mutex.lock(); +} + +USBHost::Lock::~Lock() +{ + m_pHost->usb_mutex.unlock(); +} void USBHost::transferCompleted(volatile uint32_t addr) { @@ -810,83 +822,81 @@ USB_TYPE USBHost::enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerato uint16_t total_conf_descr_length = 0; USB_TYPE res; - usb_mutex.lock(); - - // don't enumerate a device which all interfaces are registered to a specific driver - int index = findDevice(dev); - - if (index == -1) { - usb_mutex.unlock(); - return USB_TYPE_ERROR; - } - - uint8_t nb_intf_attached = numberDriverAttached(dev); - USB_DBG("dev: %p nb_intf: %d", dev, dev->getNbIntf()); - USB_DBG("dev: %p nb_intf_attached: %d", dev, nb_intf_attached); - if ((nb_intf_attached != 0) && (dev->getNbIntf() == nb_intf_attached)) { - USB_DBG("Don't enumerate dev: %p because all intf are registered with a driver", dev); - usb_mutex.unlock(); - return USB_TYPE_OK; - } - - USB_DBG("Enumerate dev: %p", dev); - - // third step: get the whole device descriptor to see vid, pid - res = getDeviceDescriptor(dev, data, DEVICE_DESCRIPTOR_LENGTH); + do + { + Lock lock(this); + + // don't enumerate a device which all interfaces are registered to a specific driver + int index = findDevice(dev); + + if (index == -1) { + return USB_TYPE_ERROR; + } + + uint8_t nb_intf_attached = numberDriverAttached(dev); + USB_DBG("dev: %p nb_intf: %d", dev, dev->getNbIntf()); + USB_DBG("dev: %p nb_intf_attached: %d", dev, nb_intf_attached); + if ((nb_intf_attached != 0) && (dev->getNbIntf() == nb_intf_attached)) { + USB_DBG("Don't enumerate dev: %p because all intf are registered with a driver", dev); + return USB_TYPE_OK; + } + + USB_DBG("Enumerate dev: %p", dev); + + // third step: get the whole device descriptor to see vid, pid + res = getDeviceDescriptor(dev, data, DEVICE_DESCRIPTOR_LENGTH); - if (res != USB_TYPE_OK) { - USB_DBG("GET DEV DESCR FAILED"); - usb_mutex.unlock(); - return res; - } - - dev->setClass(data[4]); - dev->setSubClass(data[5]); - dev->setProtocol(data[6]); - dev->setVid(data[8] | (data[9] << 8)); - dev->setPid(data[10] | (data[11] << 8)); - USB_DBG("CLASS: %02X \t VID: %04X \t PID: %04X", data[4], data[8] | (data[9] << 8), data[10] | (data[11] << 8)); + if (res != USB_TYPE_OK) { + USB_DBG("GET DEV DESCR FAILED"); + return res; + } + + dev->setClass(data[4]); + dev->setSubClass(data[5]); + dev->setProtocol(data[6]); + dev->setVid(data[8] | (data[9] << 8)); + dev->setPid(data[10] | (data[11] << 8)); + USB_DBG("CLASS: %02X \t VID: %04X \t PID: %04X", data[4], data[8] | (data[9] << 8), data[10] | (data[11] << 8)); - pEnumerator->setVidPid( data[8] | (data[9] << 8), data[10] | (data[11] << 8) ); + pEnumerator->setVidPid( data[8] | (data[9] << 8), data[10] | (data[11] << 8) ); - res = getConfigurationDescriptor(dev, data, sizeof(data), &total_conf_descr_length); - if (res != USB_TYPE_OK) { - usb_mutex.unlock(); - return res; - } + res = getConfigurationDescriptor(dev, data, sizeof(data), &total_conf_descr_length); + if (res != USB_TYPE_OK) { + return res; + } -#if (DEBUG > 3) - USB_DBG("CONFIGURATION DESCRIPTOR:\r\n"); - for (int i = 0; i < total_conf_descr_length; i++) - printf("%02X ", data[i]); - printf("\r\n\r\n"); -#endif + #if (DEBUG > 3) + USB_DBG("CONFIGURATION DESCRIPTOR:\r\n"); + for (int i = 0; i < total_conf_descr_length; i++) + printf("%02X ", data[i]); + printf("\r\n\r\n"); + #endif - // Parse the configuration descriptor - parseConfDescr(dev, data, total_conf_descr_length, pEnumerator); + // Parse the configuration descriptor + parseConfDescr(dev, data, total_conf_descr_length, pEnumerator); - // only set configuration if not enumerated before - if (!dev->isEnumerated()) { - - USB_DBG("Set configuration 1 on dev: %p", dev); - // sixth step: set configuration (only 1 supported) - res = setConfiguration(dev, 1); + // only set configuration if not enumerated before + if (!dev->isEnumerated()) { + + USB_DBG("Set configuration 1 on dev: %p", dev); + // sixth step: set configuration (only 1 supported) + res = setConfiguration(dev, 1); - if (res != USB_TYPE_OK) { - USB_DBG("SET CONF FAILED"); - usb_mutex.unlock(); - return res; - } - } - - dev->setEnumerated(); + if (res != USB_TYPE_OK) { + USB_DBG("SET CONF FAILED"); + return res; + } + } + + dev->setEnumerated(); - // Now the device is enumerated! - USB_DBG("dev %p is enumerated\r\n", dev); - usb_mutex.unlock(); + // Now the device is enumerated! + USB_DBG("dev %p is enumerated\r\n", dev); + + } while(0); // Some devices may require this delay - wait_ms(100); + Thread::wait(100); return USB_TYPE_OK; } @@ -987,38 +997,33 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui USB_DBG_TRANSFER("----- %s %s [dev: %p - %s - hub: %d - port: %d - addr: %d - ep: %02X]------", type_str, (write) ? "WRITE" : "READ", dev, dev->getName(ep->getIntfNb()), dev->getHub(), dev->getPort(), dev->getAddress(), ep->getAddress()); #endif - usb_mutex.lock(); + Lock lock(this); USB_TYPE res; ENDPOINT_DIRECTION dir = (write) ? OUT : IN; if (dev == NULL) { USB_ERR("dev NULL"); - usb_mutex.unlock(); return USB_TYPE_ERROR; } if (ep == NULL) { USB_ERR("ep NULL"); - usb_mutex.unlock(); return USB_TYPE_ERROR; } if (ep->getState() != USB_TYPE_IDLE) { USB_WARN("[ep: %p - dev: %p - %s] NOT IDLE: %s", ep, ep->dev, ep->dev->getName(ep->getIntfNb()), ep->getStateString()); - usb_mutex.unlock(); return ep->getState(); } if ((ep->getDir() != dir) || (ep->getType() != type)) { USB_ERR("[ep: %p - dev: %p] wrong dir or bad USBEndpoint type", ep, ep->dev); - usb_mutex.unlock(); return USB_TYPE_ERROR; } if (dev->getAddress() != ep->getDeviceAddress()) { USB_ERR("[ep: %p - dev: %p] USBEndpoint addr and device addr don't match", ep, ep->dev); - usb_mutex.unlock(); return USB_TYPE_ERROR; } @@ -1040,15 +1045,12 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui USB_DBG_TRANSFER("%s TRANSFER res: %s on ep: %p\r\n", type_str, ep->getStateString(), ep); if (res != USB_TYPE_IDLE) { - usb_mutex.unlock(); return res; } - usb_mutex.unlock(); return USB_TYPE_OK; } - usb_mutex.unlock(); return USB_TYPE_PROCESSING; } @@ -1064,7 +1066,7 @@ USB_TYPE USBHost::controlWrite(USBDeviceConnected * dev, uint8_t requestType, ui USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType, uint8_t request, uint32_t value, uint32_t index, uint8_t * buf, uint32_t len, bool write) { - usb_mutex.lock(); + Lock lock(this); USB_DBG_TRANSFER("----- CONTROL %s [dev: %p - hub: %d - port: %d] ------", (write) ? "WRITE" : "READ", dev, dev->getHub(), dev->getPort()); int length_transfer = len; @@ -1098,7 +1100,6 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType, USB_DBG_TRANSFER("CONTROL setup stage %s", control->getStateString()); if (res != USB_TYPE_IDLE) { - usb_mutex.unlock(); return res; } @@ -1126,7 +1127,6 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType, #endif if (res != USB_TYPE_IDLE) { - usb_mutex.unlock(); return res; } } @@ -1139,7 +1139,6 @@ USB_TYPE USBHost::controlTransfer(USBDeviceConnected * dev, uint8_t requestType, res = control->getState(); USB_DBG_TRANSFER("CONTROL ack stage %s", control->getStateString()); - usb_mutex.unlock(); if (res != USB_TYPE_IDLE) return res; diff --git a/libraries/USBHost/USBHost/USBHost.h b/libraries/USBHost/USBHost/USBHost.h index 39d59397ec..c8da421f23 100644 --- a/libraries/USBHost/USBHost/USBHost.h +++ b/libraries/USBHost/USBHost/USBHost.h @@ -187,6 +187,18 @@ public: } } + /** + * Instantiate to protect USB thread from accessing shared objects (USBConnectedDevices and Interfaces) + */ + class Lock + { + public: + Lock(USBHost* pHost); + ~Lock(); + private: + USBHost* m_pHost; + }; + friend class USBHostHub; protected: diff --git a/libraries/USBHost/USBHost3GModule/WANDongle.cpp b/libraries/USBHost/USBHost3GModule/WANDongle.cpp index e0d3cfdffe..c7896f6e62 100644 --- a/libraries/USBHost/USBHost3GModule/WANDongle.cpp +++ b/libraries/USBHost/USBHost3GModule/WANDongle.cpp @@ -20,11 +20,6 @@ #ifdef USBHOST_3GMODULE -#define __DEBUG__ 0 -#ifndef __MODULE__ -#define __MODULE__ "WANDongle.cpp" -#endif - #include "dbg.h" #include #include "rtos.h" @@ -50,10 +45,14 @@ bool WANDongle::tryConnect() USB_DBG("Trying to connect device"); if (dev_connected) { + USB_DBG("Device is already connected!"); return true; } m_pInitializer = NULL; + + //Protect from concurrent access from USB thread + USBHost::Lock lock(host); for (int i = 0; i < MAX_DEVICE_CONNECTED; i++) { diff --git a/libraries/mbed/api/DigitalIn.h b/libraries/mbed/api/DigitalIn.h index 151a49ce30..ac6812afff 100644 --- a/libraries/mbed/api/DigitalIn.h +++ b/libraries/mbed/api/DigitalIn.h @@ -49,12 +49,19 @@ public: /** Create a DigitalIn connected to the specified pin * * @param pin DigitalIn pin to connect to - * @param name (optional) A string to identify the object */ DigitalIn(PinName pin) { - gpio_init(&gpio, pin, PIN_INPUT); + gpio_init_in(&gpio, pin); } + /** Create a DigitalIn connected to the specified pin + * + * @param pin DigitalIn pin to connect to + * @param mode the initial mode of the pin + */ + DigitalIn(PinName pin, PinMode mode) { + gpio_init_in_ex(&gpio, pin, mode); + } /** Read the input, represented as 0 or 1 (int) * * @returns diff --git a/libraries/mbed/api/DigitalInOut.h b/libraries/mbed/api/DigitalInOut.h index 72aee11bbe..6778188d34 100644 --- a/libraries/mbed/api/DigitalInOut.h +++ b/libraries/mbed/api/DigitalInOut.h @@ -32,7 +32,18 @@ public: * @param pin DigitalInOut pin to connect to */ DigitalInOut(PinName pin) { - gpio_init(&gpio, pin, PIN_INPUT); + gpio_init_in(&gpio, pin); + } + + /** Create a DigitalInOut connected to the specified pin + * + * @param pin DigitalInOut pin to connect to + * @param direction the initial direction of the pin + * @param mode the initial mode of the pin + * @param value the initial value of the pin if is an output + */ + DigitalInOut(PinName pin, PinDirection direction, PinMode mode, int value) { + gpio_init_inout(&gpio, pin, direction, mode, value); } /** Set the output, specified as 0 or 1 (int) diff --git a/libraries/mbed/api/DigitalOut.h b/libraries/mbed/api/DigitalOut.h index c8445e8ea5..5ed609765a 100644 --- a/libraries/mbed/api/DigitalOut.h +++ b/libraries/mbed/api/DigitalOut.h @@ -46,7 +46,16 @@ public: * @param pin DigitalOut pin to connect to */ DigitalOut(PinName pin) { - gpio_init(&gpio, pin, PIN_OUTPUT); + gpio_init_out(&gpio, pin); + } + + /** Create a DigitalOut connected to the specified pin + * + * @param pin DigitalOut pin to connect to + * @param value the initial pin value + */ + DigitalOut(PinName pin, int value){ + gpio_init_out_ex(&gpio, pin, value); } /** Set the output, specified as 0 or 1 (int) diff --git a/libraries/mbed/api/mbed.h b/libraries/mbed/api/mbed.h index 2beef24150..b95b01a9bc 100644 --- a/libraries/mbed/api/mbed.h +++ b/libraries/mbed/api/mbed.h @@ -16,7 +16,7 @@ #ifndef MBED_H #define MBED_H -#define MBED_LIBRARY_VERSION 30 +#define MBED_LIBRARY_VERSION 80 #include "platform.h" diff --git a/libraries/mbed/common/InterruptIn.cpp b/libraries/mbed/common/InterruptIn.cpp index f553a0a020..768b517635 100644 --- a/libraries/mbed/common/InterruptIn.cpp +++ b/libraries/mbed/common/InterruptIn.cpp @@ -21,7 +21,7 @@ namespace mbed { InterruptIn::InterruptIn(PinName pin) { gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this); - gpio_init(&gpio, pin, PIN_INPUT); + gpio_init_in(&gpio, pin); } InterruptIn::~InterruptIn() { diff --git a/libraries/mbed/common/board.c b/libraries/mbed/common/board.c index e492d31754..3f6ca4aef6 100644 --- a/libraries/mbed/common/board.c +++ b/libraries/mbed/common/board.c @@ -22,15 +22,15 @@ WEAK void mbed_die(void) { #ifndef NRF51_H __disable_irq(); // dont allow interrupts to disturb the flash pattern #endif - #if (DEVICE_ERROR_RED == 1) - gpio_t led_red; gpio_init(&led_red, LED_RED, PIN_OUTPUT); + gpio_t led_red; gpio_init_out(&led_red, LED_RED); +#endif #elif (DEVICE_ERROR_PATTERN == 1) - gpio_t led_1; gpio_init(&led_1, LED1, PIN_OUTPUT); - gpio_t led_2; gpio_init(&led_2, LED2, PIN_OUTPUT); - gpio_t led_3; gpio_init(&led_3, LED3, PIN_OUTPUT); - gpio_t led_4; gpio_init(&led_4, LED4, PIN_OUTPUT); + gpio_t led_1; gpio_init_out(&led_1, LED1); + gpio_t led_2; gpio_init_out(&led_2, LED2); + gpio_t led_3; gpio_init_out(&led_3, LED3); + gpio_t led_4; gpio_init_out(&led_4, LED4); #endif while (1) { diff --git a/libraries/mbed/common/gpio.c b/libraries/mbed/common/gpio.c new file mode 100644 index 0000000000..1d820268db --- /dev/null +++ b/libraries/mbed/common/gpio.c @@ -0,0 +1,56 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ +#include "gpio_api.h" + +static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode) +{ + gpio_init(gpio, pin); + gpio_dir(gpio, PIN_INPUT); + gpio_mode(gpio, mode); +} + +static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value) +{ + gpio_init(gpio, pin); + gpio_write(gpio, value); + gpio_dir(gpio, PIN_OUTPUT); + gpio_mode(gpio, mode); +} + +void gpio_init_in(gpio_t* gpio, PinName pin) { + gpio_init_in_ex(gpio, pin, PullDefault); +} + +void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) { + _gpio_init_in(gpio, pin, mode); +} + +void gpio_init_out(gpio_t* gpio, PinName pin) { + gpio_init_out_ex(gpio, pin, 0); +} + +void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) { + _gpio_init_out(gpio, pin, PullNone, value); +} + +void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) { + if (direction == PIN_INPUT) { + _gpio_init_in(gpio, pin, mode); + gpio_write(gpio, value); // we prepare the value in case it is switched later + } else { + _gpio_init_out(gpio, pin, mode, value); + } +} diff --git a/libraries/mbed/hal/gpio_api.h b/libraries/mbed/hal/gpio_api.h index f09fbbf7bf..e4cf7fd6f5 100644 --- a/libraries/mbed/hal/gpio_api.h +++ b/libraries/mbed/hal/gpio_api.h @@ -29,7 +29,7 @@ extern "C" { uint32_t gpio_set(PinName pin); /* GPIO object */ -void gpio_init (gpio_t *obj, PinName pin, PinDirection direction); +void gpio_init(gpio_t *obj, PinName pin); void gpio_mode (gpio_t *obj, PinMode mode); void gpio_dir (gpio_t *obj, PinDirection direction); @@ -37,6 +37,13 @@ void gpio_dir (gpio_t *obj, PinDirection direction); void gpio_write(gpio_t *obj, int value); int gpio_read (gpio_t *obj); +// the following set of functions are generic and are implemented in the common gpio.c file +void gpio_init_in(gpio_t* gpio, PinName pin); +void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode); +void gpio_init_out(gpio_t* gpio, PinName pin); +void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value); +void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value); + #ifdef __cplusplus } #endif diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_MICRO/TARGET_LPC11U35_501/LPC11U35.sct b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_MICRO/TARGET_LPC11U35_501/LPC11U35.sct new file mode 100644 index 0000000000..7a8a1e2451 --- /dev/null +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_MICRO/TARGET_LPC11U35_501/LPC11U35.sct @@ -0,0 +1,20 @@ + +LR_IROM1 0x00000000 0x10000 { ; load region size_region (64k) + ER_IROM1 0x00000000 0x10000 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + } + ; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0 + ; 8KB - 0xC0 = 0x1F40 + RW_IRAM1 0x100000C0 0x1F40 { + .ANY (+RW +ZI) + } + RW_IRAM2 0x20000000 0x800 { ; RW data, I/O Handler RAM + .ANY (IOHANDLER_RAM) + } + RW_IRAM3 0x20004000 0x800 { ; RW data, USB RAM + .ANY (USBRAM) + } +} + diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_MICRO/TARGET_LPC11U35_501/startup_LPC11xx.s b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_MICRO/TARGET_LPC11U35_501/startup_LPC11xx.s new file mode 100644 index 0000000000..10ad58dc06 --- /dev/null +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_MICRO/TARGET_LPC11U35_501/startup_LPC11xx.s @@ -0,0 +1,325 @@ +;/***************************************************************************** +; * @file: startup_LPC11xx.s +; * @purpose: CMSIS Cortex-M0 Core Device Startup File +; * for the NXP LPC11xx Device Series +; * @version: V1.0 +; * @date: 25. Nov. 2008 +; *------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +; * +; * Copyright (C) 2008 ARM Limited. All rights reserved. +; * ARM Limited (ARM) is supplying this software for use with Cortex-M0 +; * processor based microcontrollers. This file can be freely distributed +; * within development tools that are supporting such ARM based processors. +; * +; * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED +; * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF +; * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. +; * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR +; * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. +; * +; *****************************************************************************/ + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 + EXPORT __initial_sp + +Stack_Mem SPACE Stack_Size +__initial_sp EQU 0x10002000 ; Top of RAM from LPC11U3x + + +Heap_Size EQU 0x00000000 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 + EXPORT __heap_base + EXPORT __heap_limit + +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + ; for LPC11Uxx (With USB) + DCD FLEX_INT0_IRQHandler ; All GPIO pin can be routed to FLEX_INTx + DCD FLEX_INT1_IRQHandler + DCD FLEX_INT2_IRQHandler + DCD FLEX_INT3_IRQHandler + DCD FLEX_INT4_IRQHandler + DCD FLEX_INT5_IRQHandler + DCD FLEX_INT6_IRQHandler + DCD FLEX_INT7_IRQHandler + DCD GINT0_IRQHandler + DCD GINT1_IRQHandler ; PIO0 (0:7) + DCD Reserved_IRQHandler ; Reserved + DCD Reserved_IRQHandler + DCD Reserved_IRQHandler + DCD Reserved_IRQHandler + DCD SSP1_IRQHandler ; SSP1 + DCD I2C_IRQHandler ; I2C + DCD TIMER16_0_IRQHandler ; 16-bit Timer0 + DCD TIMER16_1_IRQHandler ; 16-bit Timer1 + DCD TIMER32_0_IRQHandler ; 32-bit Timer0 + DCD TIMER32_1_IRQHandler ; 32-bit Timer1 + DCD SSP0_IRQHandler ; SSP0 + DCD UART_IRQHandler ; UART + DCD USB_IRQHandler ; USB IRQ + DCD USB_FIQHandler ; USB FIQ + DCD ADC_IRQHandler ; A/D Converter + DCD WDT_IRQHandler ; Watchdog timer + DCD BOD_IRQHandler ; Brown Out Detect + DCD FMC_IRQHandler ; IP2111 Flash Memory Controller + DCD Reserved_IRQHandler ; Reserved + DCD Reserved_IRQHandler ; Reserved + DCD USBWakeup_IRQHandler ; USB wake up + DCD Reserved_IRQHandler ; Reserved + + ;; 48 vector entries. We pad to 128 to fill the 0x0 - 0x1FF REMAP address space + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + IF :LNOT::DEF:NO_CRP + AREA |.ARM.__at_0x02FC|, CODE, READONLY +CRP_Key DCD 0xFFFFFFFF + ENDIF + + + AREA |.text|, CODE, READONLY + + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +; now, under COMMON NMI.c and NMI.h, a real NMI handler is created if NMI is enabled +; for particular peripheral. +;NMI_Handler PROC +; EXPORT NMI_Handler [WEAK] +; B . +; ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP +Reserved_IRQHandler PROC + EXPORT Reserved_IRQHandler [WEAK] + B . + ENDP + +Default_Handler PROC +; for LPC11Uxx (With USB) + EXPORT NMI_Handler [WEAK] + EXPORT FLEX_INT0_IRQHandler [WEAK] + EXPORT FLEX_INT1_IRQHandler [WEAK] + EXPORT FLEX_INT2_IRQHandler [WEAK] + EXPORT FLEX_INT3_IRQHandler [WEAK] + EXPORT FLEX_INT4_IRQHandler [WEAK] + EXPORT FLEX_INT5_IRQHandler [WEAK] + EXPORT FLEX_INT6_IRQHandler [WEAK] + EXPORT FLEX_INT7_IRQHandler [WEAK] + EXPORT GINT0_IRQHandler [WEAK] + EXPORT GINT1_IRQHandler [WEAK] + EXPORT SSP1_IRQHandler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT TIMER16_0_IRQHandler [WEAK] + EXPORT TIMER16_1_IRQHandler [WEAK] + EXPORT TIMER32_0_IRQHandler [WEAK] + EXPORT TIMER32_1_IRQHandler [WEAK] + EXPORT SSP0_IRQHandler [WEAK] + EXPORT UART_IRQHandler [WEAK] + + EXPORT USB_IRQHandler [WEAK] + EXPORT USB_FIQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT BOD_IRQHandler [WEAK] + EXPORT FMC_IRQHandler [WEAK] + EXPORT USBWakeup_IRQHandler [WEAK] + +NMI_Handler +FLEX_INT0_IRQHandler +FLEX_INT1_IRQHandler +FLEX_INT2_IRQHandler +FLEX_INT3_IRQHandler +FLEX_INT4_IRQHandler +FLEX_INT5_IRQHandler +FLEX_INT6_IRQHandler +FLEX_INT7_IRQHandler +GINT0_IRQHandler +GINT1_IRQHandler +SSP1_IRQHandler +I2C_IRQHandler +TIMER16_0_IRQHandler +TIMER16_1_IRQHandler +TIMER32_0_IRQHandler +TIMER32_1_IRQHandler +SSP0_IRQHandler +UART_IRQHandler +USB_IRQHandler +USB_FIQHandler +ADC_IRQHandler +WDT_IRQHandler +BOD_IRQHandler +FMC_IRQHandler +USBWakeup_IRQHandler + + B . + + ENDP + + ALIGN + END diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_STD/TARGET_LPC11U35_501/LPC11U35.sct b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_STD/TARGET_LPC11U35_501/LPC11U35.sct new file mode 100644 index 0000000000..7a8a1e2451 --- /dev/null +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_STD/TARGET_LPC11U35_501/LPC11U35.sct @@ -0,0 +1,20 @@ + +LR_IROM1 0x00000000 0x10000 { ; load region size_region (64k) + ER_IROM1 0x00000000 0x10000 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + } + ; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0 + ; 8KB - 0xC0 = 0x1F40 + RW_IRAM1 0x100000C0 0x1F40 { + .ANY (+RW +ZI) + } + RW_IRAM2 0x20000000 0x800 { ; RW data, I/O Handler RAM + .ANY (IOHANDLER_RAM) + } + RW_IRAM3 0x20004000 0x800 { ; RW data, USB RAM + .ANY (USBRAM) + } +} + diff --git a/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_STD/TARGET_LPC11U35_501/startup_LPC11xx.s b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_STD/TARGET_LPC11U35_501/startup_LPC11xx.s new file mode 100644 index 0000000000..9cf7bcd730 --- /dev/null +++ b/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_ARM_STD/TARGET_LPC11U35_501/startup_LPC11xx.s @@ -0,0 +1,308 @@ +;/***************************************************************************** +; * @file: startup_LPC11xx.s +; * @purpose: CMSIS Cortex-M0 Core Device Startup File +; * for the NXP LPC11xx Device Series +; * @version: V1.0 +; * @date: 25. Nov. 2008 +; *------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +; * +; * Copyright (C) 2008 ARM Limited. All rights reserved. +; * ARM Limited (ARM) is supplying this software for use with Cortex-M0 +; * processor based microcontrollers. This file can be freely distributed +; * within development tools that are supporting such ARM based processors. +; * +; * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED +; * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF +; * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. +; * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR +; * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. +; * +; *****************************************************************************/ + +__initial_sp EQU 0x10002000 ; Top of RAM from LPC11U3x + + PRESERVE8 + THUMB + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + ; for LPC11Uxx (With USB) + DCD FLEX_INT0_IRQHandler ; All GPIO pin can be routed to FLEX_INTx + DCD FLEX_INT1_IRQHandler + DCD FLEX_INT2_IRQHandler + DCD FLEX_INT3_IRQHandler + DCD FLEX_INT4_IRQHandler + DCD FLEX_INT5_IRQHandler + DCD FLEX_INT6_IRQHandler + DCD FLEX_INT7_IRQHandler + DCD GINT0_IRQHandler + DCD GINT1_IRQHandler ; PIO0 (0:7) + DCD Reserved_IRQHandler ; Reserved + DCD Reserved_IRQHandler + DCD Reserved_IRQHandler + DCD Reserved_IRQHandler + DCD SSP1_IRQHandler ; SSP1 + DCD I2C_IRQHandler ; I2C + DCD TIMER16_0_IRQHandler ; 16-bit Timer0 + DCD TIMER16_1_IRQHandler ; 16-bit Timer1 + DCD TIMER32_0_IRQHandler ; 32-bit Timer0 + DCD TIMER32_1_IRQHandler ; 32-bit Timer1 + DCD SSP0_IRQHandler ; SSP0 + DCD UART_IRQHandler ; UART + DCD USB_IRQHandler ; USB IRQ + DCD USB_FIQHandler ; USB FIQ + DCD ADC_IRQHandler ; A/D Converter + DCD WDT_IRQHandler ; Watchdog timer + DCD BOD_IRQHandler ; Brown Out Detect + DCD FMC_IRQHandler ; IP2111 Flash Memory Controller + DCD Reserved_IRQHandler ; Reserved + DCD Reserved_IRQHandler ; Reserved + DCD USBWakeup_IRQHandler ; USB wake up + DCD Reserved_IRQHandler ; Reserved + + ;; 48 vector entries. We pad to 128 to fill the 0x0 - 0x1FF REMAP address space + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + DCD 0xFFFFFFFF ; Datafill + + IF :LNOT::DEF:NO_CRP + AREA |.ARM.__at_0x02FC|, CODE, READONLY +CRP_Key DCD 0xFFFFFFFF + ENDIF + + + AREA |.text|, CODE, READONLY + + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +; now, under COMMON NMI.c and NMI.h, a real NMI handler is created if NMI is enabled +; for particular peripheral. +;NMI_Handler PROC +; EXPORT NMI_Handler [WEAK] +; B . +; ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP +Reserved_IRQHandler PROC + EXPORT Reserved_IRQHandler [WEAK] + B . + ENDP + +Default_Handler PROC +; for LPC11Uxx (With USB) + EXPORT NMI_Handler [WEAK] + EXPORT FLEX_INT0_IRQHandler [WEAK] + EXPORT FLEX_INT1_IRQHandler [WEAK] + EXPORT FLEX_INT2_IRQHandler [WEAK] + EXPORT FLEX_INT3_IRQHandler [WEAK] + EXPORT FLEX_INT4_IRQHandler [WEAK] + EXPORT FLEX_INT5_IRQHandler [WEAK] + EXPORT FLEX_INT6_IRQHandler [WEAK] + EXPORT FLEX_INT7_IRQHandler [WEAK] + EXPORT GINT0_IRQHandler [WEAK] + EXPORT GINT1_IRQHandler [WEAK] + EXPORT SSP1_IRQHandler [WEAK] + EXPORT I2C_IRQHandler [WEAK] + EXPORT TIMER16_0_IRQHandler [WEAK] + EXPORT TIMER16_1_IRQHandler [WEAK] + EXPORT TIMER32_0_IRQHandler [WEAK] + EXPORT TIMER32_1_IRQHandler [WEAK] + EXPORT SSP0_IRQHandler [WEAK] + EXPORT UART_IRQHandler [WEAK] + + EXPORT USB_IRQHandler [WEAK] + EXPORT USB_FIQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT BOD_IRQHandler [WEAK] + EXPORT FMC_IRQHandler [WEAK] + EXPORT USBWakeup_IRQHandler [WEAK] + +NMI_Handler +FLEX_INT0_IRQHandler +FLEX_INT1_IRQHandler +FLEX_INT2_IRQHandler +FLEX_INT3_IRQHandler +FLEX_INT4_IRQHandler +FLEX_INT5_IRQHandler +FLEX_INT6_IRQHandler +FLEX_INT7_IRQHandler +GINT0_IRQHandler +GINT1_IRQHandler +SSP1_IRQHandler +I2C_IRQHandler +TIMER16_0_IRQHandler +TIMER16_1_IRQHandler +TIMER32_0_IRQHandler +TIMER32_1_IRQHandler +SSP0_IRQHandler +UART_IRQHandler +USB_IRQHandler +USB_FIQHandler +ADC_IRQHandler +WDT_IRQHandler +BOD_IRQHandler +FMC_IRQHandler +USBWakeup_IRQHandler + + B . + + ENDP + + ALIGN + END diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx.h index c73bfa2c23..e0d005eb59 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx.h @@ -25,19 +25,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_adc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_adc.c index 0a8c56d9e8..dc1b032fa4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_adc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_adc.c @@ -55,19 +55,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_adc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_adc.h index b570068792..d48c5d98e0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_adc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_adc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.c index 7dcae51e2a..9ac12e0ec8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.c @@ -51,19 +51,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.h index 60a4098c14..0f7efc3724 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_can.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_cec.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_cec.c index f6b4294a7e..8202c469fc 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_cec.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_cec.c @@ -72,19 +72,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_cec.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_cec.h index 29f06a6844..8c41f39440 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_cec.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_cec.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_comp.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_comp.c index f4b279c045..d78458be75 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_comp.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_comp.c @@ -78,19 +78,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_comp.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_comp.h index da8b152a5d..dabee917d3 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_comp.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_comp.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_conf.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_conf.h index 35dcdd702d..5283cd5e09 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_conf.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_conf.h @@ -8,19 +8,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.c index 05e1bf1f1e..d1adb161e0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.c @@ -34,19 +34,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.h index ef1d4369ab..0ce5c3225a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crs.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crs.c index 3d35149b4d..bf58f34992 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crs.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crs.c @@ -26,19 +26,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crs.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crs.h index 6f37b4f0d3..622bfd21ec 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crs.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crs.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dac.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dac.c index e6f34adf13..468f360003 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dac.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dac.c @@ -87,19 +87,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dac.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dac.h index f2884bba9a..fd0699a03a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dac.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dac.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.c index 3965733996..0d721c5af1 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.c @@ -14,19 +14,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.h index 0ce7130832..571e857fc8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dbgmcu.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dma.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dma.c index 73492c5417..141f77ca0c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dma.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dma.c @@ -50,19 +50,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dma.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dma.h index d24decb91e..95639bc7d7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dma.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_dma.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_exti.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_exti.c index 684a7deb9b..9a360927db 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_exti.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_exti.c @@ -49,19 +49,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_exti.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_exti.h index f2231664c0..9d31125a93 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_exti.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_exti.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_flash.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_flash.c index e548c4488b..6cf35497b7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_flash.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_flash.c @@ -55,19 +55,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_flash.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_flash.h index 40a2976d2c..e510bc2a4a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_flash.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_flash.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_gpio.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_gpio.c index 880508c44c..ae0c269a01 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_gpio.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_gpio.c @@ -55,19 +55,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_gpio.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_gpio.h index b2625b6a3f..005538a4ca 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_gpio.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_gpio.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_i2c.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_i2c.c index 05a79662e3..e31c6c965a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_i2c.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_i2c.c @@ -58,19 +58,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_i2c.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_i2c.h index 1c56b9c968..8fa4f66c1f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_i2c.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_i2c.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.c index 2eca2c83c9..6f33956416 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.c @@ -77,19 +77,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.h index 4ad0f38272..29ff2f266c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_iwdg.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_misc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_misc.c index 1ace673c89..13e0010872 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_misc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_misc.c @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_misc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_misc.h index f5ea6bd582..6159605661 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_misc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_misc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_pwr.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_pwr.c index 7c13ce4203..23ef9badc5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_pwr.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_pwr.c @@ -15,19 +15,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_pwr.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_pwr.h index 491368c193..bf5349719f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_pwr.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_pwr.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rcc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rcc.c index ef8d5fda2b..82b4d6184d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rcc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rcc.c @@ -37,19 +37,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rcc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rcc.h index cd0899c317..6f168ce2a5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rcc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rcc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rtc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rtc.c index 58b9978b21..1f7452628c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rtc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rtc.c @@ -213,19 +213,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rtc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rtc.h index 598ed660d9..a77be510fe 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rtc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_rtc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_spi.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_spi.c index e0c148b4f7..4ad238abf7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_spi.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_spi.c @@ -73,19 +73,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_spi.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_spi.h index 7b95f833c6..848e58d610 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_spi.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_spi.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.c index 518cf2ac8d..3e80598f3b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.c @@ -27,19 +27,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.h index 1a1d56618e..09ac8ee5d2 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_syscfg.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_tim.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_tim.c index f7b428728a..83450802de 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_tim.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_tim.c @@ -96,19 +96,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_tim.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_tim.h index 1b7c74543f..065e7fd1a5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_tim.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_tim.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_usart.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_usart.c index 43392f0b61..beb6073dc0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_usart.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_usart.c @@ -60,19 +60,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_usart.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_usart.h index c9d170a119..d7c090f880 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_usart.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_usart.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.c index ab92920dea..6605abf497 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.c @@ -65,19 +65,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.h index 49defe551d..b53d466513 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_wwdg.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/system_stm32f0xx.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/system_stm32f0xx.c index e6c115bfaa..4b65d8b2c8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/system_stm32f0xx.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/system_stm32f0xx.c @@ -65,19 +65,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/system_stm32f0xx.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/system_stm32f0xx.h index ab76a00554..78d9460404 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/system_stm32f0xx.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/system_stm32f0xx.h @@ -8,19 +8,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s index 930ca468e1..973e0fb050 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s @@ -1,31 +1,43 @@ -; STM32F40xx/41xx devices vector table for MDK-ARM MICRO toolchain -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Copyright (c) 2014, STMicroelectronics -; All rights reserved. -; -; Redistribution and use in source and binary forms, with or without -; modification, are permitted provided that the following conditions are met: -; -; 1. Redistributions of source code must retain the above copyright notice, -; this list of conditions and the following disclaimer. -; 2. Redistributions in binary form must reproduce the above copyright notice, -; this list of conditions and the following disclaimer in the documentation -; and/or other materials provided with the distribution. -; 3. Neither the name of STMicroelectronics nor the names of its contributors -; may be used to endorse or promote products derived from this software -; without specific prior written permission. -; -; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;******************** (C) COPYRIGHT 2014 STMicroelectronics ******************** +;* File Name : startup_stm32f401xe.s +;* Author : MCD Application Team +;* Version : V2.0.0 +;* Date : 18-February-2014 +;* Description : STM32F401xe devices vector table for MDK-ARM toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM4 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; +;* Redistribution and use in source and binary forms, with or without modification, +;* are permitted provided that the following conditions are met: +;* 1. Redistributions of source code must retain the above copyright notice, +;* this list of conditions and the following disclaimer. +;* 2. Redistributions in binary form must reproduce the above copyright notice, +;* this list of conditions and the following disclaimer in the documentation +;* and/or other materials provided with the distribution. +;* 3. Neither the name of STMicroelectronics nor the names of its contributors +;* may be used to endorse or promote products derived from this software +;* without specific prior written permission. +;* +;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +; +;******************************************************************************* ; Amount of memory (in bytes) allocated for Stack ; Tailor this value to your application needs diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s index 404dfee502..24e135371f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s @@ -1,31 +1,43 @@ -; STM32F40xx/41xx devices vector table for MDK-ARM toolchain -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Copyright (c) 2014, STMicroelectronics -; All rights reserved. -; -; Redistribution and use in source and binary forms, with or without -; modification, are permitted provided that the following conditions are met: -; -; 1. Redistributions of source code must retain the above copyright notice, -; this list of conditions and the following disclaimer. -; 2. Redistributions in binary form must reproduce the above copyright notice, -; this list of conditions and the following disclaimer in the documentation -; and/or other materials provided with the distribution. -; 3. Neither the name of STMicroelectronics nor the names of its contributors -; may be used to endorse or promote products derived from this software -; without specific prior written permission. -; -; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;******************** (C) COPYRIGHT 2014 STMicroelectronics ******************** +;* File Name : startup_stm32f401xe.s +;* Author : MCD Application Team +;* Version : V2.0.0 +;* Date : 18-February-2014 +;* Description : STM32F401xe devices vector table for MDK-ARM toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM4 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; +;* Redistribution and use in source and binary forms, with or without modification, +;* are permitted provided that the following conditions are met: +;* 1. Redistributions of source code must retain the above copyright notice, +;* this list of conditions and the following disclaimer. +;* 2. Redistributions in binary form must reproduce the above copyright notice, +;* this list of conditions and the following disclaimer in the documentation +;* and/or other materials provided with the distribution. +;* 3. Neither the name of STMicroelectronics nor the names of its contributors +;* may be used to endorse or promote products derived from this software +;* without specific prior written permission. +;* +;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +; +;******************************************************************************* __initial_sp EQU 0x20018000 ; Top of RAM diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_IAR/startup_stm32f401xe.s b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_IAR/startup_stm32f401xe.s index 204c99f7cc..cc55d51303 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_IAR/startup_stm32f401xe.s +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_IAR/startup_stm32f401xe.s @@ -1,8 +1,8 @@ ;/******************** (C) COPYRIGHT 2014 STMicroelectronics ******************** ;* File Name : startup_stm32f401xe.s ;* Author : MCD Application Team -;* Version : V2.0.0RC6 -;* Date : 03-February-2014 +;* Version : V2.0.0 +;* Date : 18-February-2014 ;* Description : STM32F401xExx devices vector table for EWARM toolchain. ;* This module performs: ;* - Set the initial SP diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f401xe.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f401xe.h index e27fe623e0..d49f3ef086 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f401xe.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f401xe.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f401xe.h * @author MCD Application Team - * @version V2.0.0RC6 - * @date 03-February-2014 + * @version V2.0.0 + * @date 18-February-2014 * @brief CMSIS STM32F401xExx Device Peripheral Access Layer Header File. * * This file contains: @@ -678,15 +678,15 @@ USB_OTG_HostChannelTypeDef; */ #define FLASH_BASE ((uint32_t)0x08000000) /*!< FLASH(up to 1 MB) base address in the alias region */ #define CCMDATARAM_BASE ((uint32_t)0x10000000) /*!< CCM(core coupled memory) data RAM(64 KB) base address in the alias region */ -#define SRAM1_BASE ((uint32_t)0x20000000) /*!< SRAM1(112 KB) base address in the alias region */ -#define SRAM2_BASE ((uint32_t)0x2001C000) /*!< SRAM2(16 KB) base address in the alias region */ -#define SRAM3_BASE ((uint32_t)0x20020000) /*!< SRAM3(64 KB) base address in the alias region */ +#define SRAM1_BASE ((uint32_t)0x20000000) /*!< SRAM1(96 KB) base address in the alias region */ +//#define SRAM2_BASE ((uint32_t)0x2001C000) /*!< SRAM2(16 KB) base address in the alias region */ +//#define SRAM3_BASE ((uint32_t)0x20020000) /*!< SRAM3(64 KB) base address in the alias region */ #define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */ #define BKPSRAM_BASE ((uint32_t)0x40024000) /*!< Backup SRAM(4 KB) base address in the alias region */ #define CCMDATARAM_BB_BASE ((uint32_t)0x12000000) /*!< CCM(core coupled memory) data RAM(64 KB) base address in the bit-band region */ -#define SRAM1_BB_BASE ((uint32_t)0x22000000) /*!< SRAM1(112 KB) base address in the bit-band region */ -#define SRAM2_BB_BASE ((uint32_t)0x2201C000) /*!< SRAM2(16 KB) base address in the bit-band region */ -#define SRAM3_BB_BASE ((uint32_t)0x22020000) /*!< SRAM3(64 KB) base address in the bit-band region */ +#define SRAM1_BB_BASE ((uint32_t)0x22000000) /*!< SRAM1(96 KB) base address in the bit-band region */ +//#define SRAM2_BB_BASE ((uint32_t)0x2201C000) /*!< SRAM2(16 KB) base address in the bit-band region */ +//#define SRAM3_BB_BASE ((uint32_t)0x22020000) /*!< SRAM3(64 KB) base address in the bit-band region */ #define PERIPH_BB_BASE ((uint32_t)0x42000000) /*!< Peripheral base address in the bit-band region */ #define BKPSRAM_BB_BASE ((uint32_t)0x42024000) /*!< Backup SRAM(4 KB) base address in the bit-band region */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx.h index a440fe4177..a9c53278d6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx.h * @author MCD Application Team - * @version V2.0.0RC6 - * @date 03-February-2014 + * @version V2.0.0 + * @date 18-February-2014 * @brief CMSIS STM32F4xx Device Peripheral Access Layer Header File. * * The file is the unique include file that the application programmer @@ -94,16 +94,16 @@ In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers */ - /*#define USE_HAL_DRIVER */ +#define USE_HAL_DRIVER #endif /* USE_HAL_DRIVER */ /** - * @brief CMSIS Device version number V2.0.0RC6 + * @brief CMSIS Device version number V2.0.0 */ #define __STM32F4xx_CMSIS_DEVICE_VERSION_MAIN (0x02) /*!< [31:24] main version */ #define __STM32F4xx_CMSIS_DEVICE_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ #define __STM32F4xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ -#define __STM32F4xx_CMSIS_DEVICE_VERSION_RC (0x06) /*!< [7:0] release candidate */ +#define __STM32F4xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */ #define __STM32F4xx_CMSIS_DEVICE_VERSION ((__CMSIS_DEVICE_VERSION_MAIN << 24)\ |(__CMSIS_DEVICE_HAL_VERSION_SUB1 << 16)\ |(__CMSIS_DEVICE_HAL_VERSION_SUB2 << 8 )\ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.c index a47ef8bb1c..858397f1a6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief HAL module driver. * This is the common part of the HAL initialization * @@ -62,17 +62,15 @@ * @{ */ -#ifdef HAL_MODULE_ENABLED - /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /** - * @brief STM32F4xx HAL Driver version number V1.0.0RC1 + * @brief STM32F4xx HAL Driver version number V1.0.0 */ #define __STM32F4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */ #define __STM32F4xx_HAL_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ #define __STM32F4xx_HAL_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ -#define __STM32F4xx_HAL_VERSION_RC (0x01) /*!< [7:0] release candidate */ +#define __STM32F4xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */ #define __STM32F4xx_HAL_VERSION ((__STM32F4xx_HAL_VERSION_MAIN << 24)\ |(__STM32F4xx_HAL_VERSION_SUB1 << 16)\ |(__STM32F4xx_HAL_VERSION_SUB2 << 8 )\ @@ -96,6 +94,7 @@ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static __IO uint32_t uwTick; + /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ @@ -121,18 +120,20 @@ static __IO uint32_t uwTick; */ /** - * @brief This function configures the Flash prefetch, instruction and Data caches, - * Configures systick, NVIC and Low level hardware - * - * @note This function is called at the beginning of program after reset and before - * the clock configuration - * - * @note The Systick configuration is based on HSI clock, as HSI is the clock - * used after a system Reset and the NVIC configuration is set to Priority group 4 + * @brief This function is used to initialize the HAL Library; it must be the first + * instruction to be executed in the main program (before to call any other + * HAL function), it performs the following: + * - Configure the Flash prefetch, instruction and Data caches + * - Configures the SysTick to generate an interrupt each 1 millisecond, + * which is clocked by the HSI (at this stage, the clock is not yet + * configured and thus the system is running from the internal HSI at 16 MHz) + * - Set NVIC Group Priority to 4 + * - Calls the HAL_MspInit() callback function defined in user file + * stm32f4xx_hal_msp.c to do the global low level hardware initialization * - * @note The Systick Interrupt is defined with the lowest priority in "core_cm4.h" file - * In this case HAL_Delay() must not be used under interrupt with higher priority. - * + * @note SysTick is used as time base for the HAL_Delay() function, the application + * need to ensure that the SysTick time base is always set to 1 millisecond + * to have correct HAL operation. * @note * @param None * @retval HAL status @@ -247,8 +248,8 @@ __weak void HAL_MspDeInit(void) */ /** - * @brief This function is used when systick configuration should be changed. - * It is used to provide the HAL a timer base service. + * @brief This function is called from SysTick ISR each 1 millisecond, to increment + * a global variable "uwTick" used as time base. * @param None * @retval None */ @@ -258,7 +259,7 @@ void HAL_IncTick(void) } /** - * @brief This method used to provide a tick value in millisecond. + * @brief Povides a tick value in millisecond. * @param Non * @retval tick value */ @@ -268,7 +269,13 @@ uint32_t HAL_GetTick(void) } /** - * @brief This method used to provide blocking delay + * @brief Provides a blocking delay in millisecond. + * @note Care must be taken when using HAL_Delay(), this function provides accurate delay + * (in milliseconds) based on variable incremented in SysTick ISR. This implies that + * if HAL_Delay() is called from a peripheral ISR process, then the SysTick interrupt + * must have higher priority (numerically lower) than the peripheral interrupt. + * Otherwise the caller ISR process will be blocked. To change the SysTick interrupt + * priority you have to use HAL_NVIC_SetPriority() function. * @param Delay : specifies the delay time length, in milliseconds. * @retval None */ @@ -283,7 +290,7 @@ void HAL_Delay(__IO uint32_t Delay) } /** - * @brief This method returns the HAL revision + * @brief Returns the HAL revision * @param None * @retval version : 0xXYZR (8bits for each decimal, R for RC) */ @@ -435,7 +442,6 @@ void HAL_DisableMemorySwappingBank(void) * @} */ -#endif /* HAL_MODULE_ENABLED */ /** * @} */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.h index e3dbbaafe0..48c87474ba 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief This file contains all the functions prototypes for the HAL * module driver. ****************************************************************************** @@ -109,40 +109,40 @@ /** @brief Main Flash memory mapped at 0x00000000 */ -#define __HAL_REMAPMEMORY_FLASH (SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE)) +#define __HAL_REMAPMEMORY_FLASH() (SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE)) /** @brief System Flash memory mapped at 0x00000000 */ -#define __HAL_REMAPMEMORY_SYSTEMFLASH do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ - SYSCFG->MEMRMP |= SYSCFG_MEMRMP_MEM_MODE_0;\ - }while(0); +#define __HAL_REMAPMEMORY_SYSTEMFLASH() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ + SYSCFG->MEMRMP |= SYSCFG_MEMRMP_MEM_MODE_0;\ + }while(0); /** @brief Embedded SRAM mapped at 0x00000000 */ -#define __HAL_REMAPMEMORY_SRAM do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ - SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_0 | SYSCFG_MEMRMP_MEM_MODE_1);\ - }while(0); +#define __HAL_REMAPMEMORY_SRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ + SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_0 | SYSCFG_MEMRMP_MEM_MODE_1);\ + }while(0); #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) /** @brief FSMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 */ -#define __HAL_REMAPMEMORY_FSMC do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ - SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ - }while(0); +#define __HAL_REMAPMEMORY_FSMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ + SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ + }while(0); #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) /** @brief FMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 */ -#define __HAL_REMAPMEMORY_FMC do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ - SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ - }while(0); +#define __HAL_REMAPMEMORY_FMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ + SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ + }while(0); /** @brief FMC/SDRAM Bank 1 and 2 mapped at 0x00000000 */ -#define __HAL_REMAPMEMORY_FMC_SDRAM do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ - SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_2);\ - }while(0); +#define __HAL_REMAPMEMORY_FMC_SDRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ + SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_2);\ + }while(0); #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ /* Exported functions --------------------------------------------------------*/ @@ -150,8 +150,8 @@ /* Initialization and de-initialization functions ******************************/ HAL_StatusTypeDef HAL_Init(void); HAL_StatusTypeDef HAL_DeInit(void); -__weak void HAL_MspInit(void); -__weak void HAL_MspDeInit(void); +void HAL_MspInit(void); +void HAL_MspDeInit(void); /* Peripheral Control functions ************************************************/ void HAL_IncTick(void); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c index 9fb1f0106d..bd48131ceb 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_adc.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief This file provides firmware functions to manage the following * functionalities of the Analog to Digital Convertor (ADC) peripheral: * + Initialization and de-initialization functions @@ -242,7 +242,10 @@ HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc) /* Initialize the ADC state */ hadc->State = HAL_ADC_STATE_READY; - + + /* Release Lock */ + __HAL_UNLOCK(hadc); + /* Return function status */ return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h index 6bf78442e5..0e1ef89937 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_adc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of ADC HAL extension module. ****************************************************************************** * @attention @@ -687,8 +687,8 @@ typedef struct /* Initialization/de-initialization functions ***********************************/ HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc); HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc); -__weak void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc); -__weak void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc); +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc); +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc); /* I/O operation functions ******************************************************/ HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc); @@ -707,10 +707,10 @@ HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc); uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc); -__weak void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc); -__weak void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc); -__weak void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc); -__weak void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc); +void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc); +void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc); +void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc); +void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc); /* Peripheral Control functions *************************************************/ HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c index 4fc415062d..d00e35ab75 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_adc_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief This file provides firmware functions to manage the following * functionalities of the ADC extension peripheral: * + Extended features functions diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.h index 0bebbf2e45..3e94ac2b9b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_adc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of ADC HAL module. ****************************************************************************** * @attention @@ -264,7 +264,7 @@ uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t I HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length); HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef* hadc); uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef* hadc); -__weak void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc); +void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc); /* Peripheral Control functions *************************************************/ HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c index e7cf750d7e..dd123b6e9b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_can.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief This file provides firmware functions to manage the following * functionalities of the Controller Area Network (CAN) peripheral: * + Initialization and de-initialization functions @@ -459,7 +459,10 @@ HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef* hcan) /* Change CAN state */ hcan->State = HAL_CAN_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hcan); + /* Return function status */ return HAL_OK; } @@ -1166,7 +1169,7 @@ void HAL_CAN_IRQHandler(CAN_HandleTypeDef* hcan) } /* Call the Error call Back in case of Errors */ - if(hcan->ErrorCode != HAL_IRDA_ERROR_NONE) + if(hcan->ErrorCode != HAL_CAN_ERROR_NONE) { /* Set the CAN state ready to be able to start again the process */ hcan->State = HAL_CAN_STATE_READY; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h index 7a477cc912..930f632d3f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_can.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_can.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of CAN HAL module. ****************************************************************************** * @attention @@ -735,8 +735,8 @@ typedef struct HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef* hcan); HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef* hcan, CAN_FilterConfTypeDef* sFilterConfig); HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef* hcan); -__weak void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan); -__weak void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan); +void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan); +void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan); /* I/O operation functions ******************************************************/ HAL_StatusTypeDef HAL_CAN_Transmit(CAN_HandleTypeDef *hcan, uint32_t Timeout); @@ -751,9 +751,9 @@ void HAL_CAN_IRQHandler(CAN_HandleTypeDef* hcan); uint32_t HAL_CAN_GetError(CAN_HandleTypeDef *hcan); HAL_CAN_StateTypeDef HAL_CAN_GetState(CAN_HandleTypeDef* hcan); -__weak void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* hcan); -__weak void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan); -__weak void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan); +void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* hcan); +void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan); +void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan); #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h index 50ffee0513..5878af328b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_conf.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_conf_template.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f4xx_hal_conf.h. @@ -99,7 +99,7 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ + #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External crystal in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.c index e9c5093866..57e07b6288 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cortex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief CORTEX HAL module driver. * This file provides firmware functions to manage the following * functionalities of the CORTEX: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.h index 3327b9d3f7..b964bbaea9 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cortex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cortex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of CORTEX HAL module. ****************************************************************************** * @attention @@ -143,7 +143,7 @@ void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn); uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn); void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource); void HAL_SYSTICK_IRQHandler(void); -__weak void HAL_SYSTICK_Callback(void); +void HAL_SYSTICK_Callback(void); /** * @} diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c index eab3799b5d..59ca9fedc5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_crc.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief CRC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Cyclic Redundancy Check (CRC) peripheral: @@ -160,6 +160,9 @@ HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc) /* Change CRC peripheral state */ hcrc->State = HAL_CRC_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hcrc); + /* Return function status */ return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h index 462a3a0d20..8e97e702f5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_crc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_crc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of CRC HAL module. ****************************************************************************** * @attention @@ -97,8 +97,8 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc); HAL_StatusTypeDef HAL_CRC_DeInit (CRC_HandleTypeDef *hcrc); -__weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc); -__weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc); +void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc); +void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc); /* Peripheral Control functions ************************************************/ uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c index f9e4b56331..ab93244467 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cryp.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief CRYP HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Cryptography (CRYP) peripheral: @@ -233,7 +233,10 @@ HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp) /* Change the CRYP state */ hcryp->State = HAL_CRYP_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hcryp); + /* Return function status */ return HAL_OK; } @@ -1038,7 +1041,7 @@ HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t /* Change state */ hcryp->State = HAL_CRYP_STATE_TIMEOUT; - /* Process Unlocked */ + /* Process Unlocked */ __HAL_UNLOCK(hcryp); return HAL_TIMEOUT; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h index 8814545c52..fddff61ed8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cryp.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of CRYP HAL module. ****************************************************************************** * @attention @@ -375,13 +375,13 @@ void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); /* MSP functions *************************************************************/ -__weak void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); -__weak void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); +void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); +void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); /* CallBack functions ********************************************************/ -__weak void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); -__weak void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); -__weak void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); +void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); +void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); +void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.c index 393f23245a..8887047525 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cryp_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Extended CRYP HAL module driver * This file provides firmware functions to manage the following * functionalities of CRYP extension peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.h index 2636e9ea57..7ac7f78df6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_cryp_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of CRYP HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c index 758cafab4b..598e1e0934 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dac.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief DAC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Digital to Analog Converter (DAC) peripheral: @@ -263,22 +263,25 @@ HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac) { return HAL_ERROR; } - + /* Check the parameters */ assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance)); - + /* Change DAC state */ hdac->State = HAL_DAC_STATE_BUSY; - + /* DeInit the low level hardware */ HAL_DAC_MspDeInit(hdac); - + /* Set DAC error code to none */ hdac->ErrorCode = HAL_DAC_ERROR_NONE; - + /* Change DAC state */ hdac->State = HAL_DAC_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hdac); + /* Return function status */ return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h index 87dcb37331..863ef3fbf4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dac.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of DAC HAL module. ****************************************************************************** * @attention @@ -253,8 +253,8 @@ typedef struct /* Initialization/de-initialization functions ***********************************/ HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac); HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac); -__weak void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac); -__weak void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac); +void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac); +void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac); /* I/O operation functions ******************************************************/ HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel); @@ -272,10 +272,10 @@ HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac); void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac); uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac); -__weak void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac); -__weak void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac); -__weak void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac); -__weak void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac); +void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac); +void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac); +void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac); +void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac); #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.c index 18716f4213..1ddea46698 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dac_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief DAC HAL module driver. * This file provides firmware functions to manage the following * functionalities of DAC extension peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.h index 9250d52c57..6b3617c06e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dac_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dac.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of DAC HAL Extension module. ****************************************************************************** * @attention @@ -155,10 +155,10 @@ HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32 HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude); HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2); -__weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac); -__weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac); -__weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef* hdac); -__weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef* hdac); +void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac); +void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac); +void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef* hdac); +void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef* hdac); void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma); void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c index 96d2f38d25..f21e7f7c98 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dcmi.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief DCMI HAL module driver * This file provides firmware functions to manage the following * functionalities of the Digital Camera Interface (DCMI) peripheral: @@ -54,7 +54,7 @@ (+) __HAL_DCMI_CLEAR_FLAG: Clear the DCMI pending flags. (+) __HAL_DCMI_ENABLE_IT: Enable the specified DCMI interrupts. (+) __HAL_DCMI_DISABLE_IT: Disable the specified DCMI interrupts. - (+) __HAL_DCMI_IT_STATUS: Check whether the specified DCMI interrupt has occurred or not. + (+) __HAL_DCMI_GET_IT_SOURCE: Check whether the specified DCMI interrupt has occurred or not. [..] (@) You can refer to the DCMI HAL driver header file for more useful macros @@ -110,8 +110,8 @@ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ -static void HAL_DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma); -static void HAL_DCMI_DMAError(DMA_HandleTypeDef *hdma); +static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma); +static void DCMI_DMAError(DMA_HandleTypeDef *hdma); /* Private functions ---------------------------------------------------------*/ @@ -231,6 +231,9 @@ HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi) /* Initialize the DCMI state*/ hdcmi->State = HAL_DCMI_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hdcmi); + return HAL_OK; } @@ -311,10 +314,10 @@ HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mo hdcmi->Instance->CR |= (uint32_t)(DCMI_Mode); /* Set the DMA memory0 conversion complete callback */ - hdcmi->DMA_Handle->XferCpltCallback = HAL_DCMI_DMAConvCplt; + hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAConvCplt; /* Set the DMA error callback */ - hdcmi->DMA_Handle->XferErrorCallback = HAL_DCMI_DMAError; + hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError; if(Length <= 0xFFFF) { @@ -324,7 +327,7 @@ HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mo else /* DCMI_DOUBLE_BUFFER Mode */ { /* Set the DMA memory1 conversion complete callback */ - hdcmi->DMA_Handle->XferM1CpltCallback = HAL_DCMI_DMAConvCplt; + hdcmi->DMA_Handle->XferM1CpltCallback = DCMI_DMAConvCplt; /* Initialise transfer parameters */ hdcmi->XferCount = 1; @@ -421,7 +424,7 @@ void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) /* Synchronization error interrupt management *******************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_ERRRI) != RESET) { - if(__HAL_DCMI_IT_STATUS(hdcmi, DCMI_IT_ERR) != RESET) + if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_ERR) != RESET) { /* Disable the Synchronization error interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_ERR); @@ -448,7 +451,7 @@ void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) /* Overflow interrupt management ********************************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_OVFRI) != RESET) { - if(__HAL_DCMI_IT_STATUS(hdcmi, DCMI_IT_OVF) != RESET) + if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_OVF) != RESET) { /* Disable the Overflow interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_OVF); @@ -475,7 +478,7 @@ void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) /* Line Interrupt management ************************************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_LINERI) != RESET) { - if(__HAL_DCMI_IT_STATUS(hdcmi, DCMI_IT_LINE) != RESET) + if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_LINE) != RESET) { /* Clear the Line interrupt flag */ __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_LINERI); @@ -490,7 +493,7 @@ void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) /* VSYNC interrupt management ***********************************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_VSYNCRI) != RESET) { - if(__HAL_DCMI_IT_STATUS(hdcmi, DCMI_IT_VSYNC) != RESET) + if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_VSYNC) != RESET) { /* Disable the VSYNC interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_VSYNC); @@ -508,7 +511,7 @@ void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) /* End of Frame interrupt management ****************************************/ if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET) { - if(__HAL_DCMI_IT_STATUS(hdcmi, DCMI_IT_FRAME) != RESET) + if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_FRAME) != RESET) { /* Disable the End of Frame interrupt */ __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_FRAME); @@ -736,7 +739,7 @@ uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi) * @param hdma: pointer to DMA handle. * @retval None */ -static void HAL_DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma) +static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma) { uint32_t tmp = 0; @@ -789,7 +792,7 @@ static void HAL_DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma) * @param hdma: pointer to DMA handle. * @retval None */ -static void HAL_DCMI_DMAError(DMA_HandleTypeDef *hdma) +static void DCMI_DMAError(DMA_HandleTypeDef *hdma) { DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; hdcmi->State= HAL_DCMI_STATE_READY; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h index b9b0b38e3a..11b07c1d04 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dcmi.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dcmi.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of DCMI HAL module. ****************************************************************************** * @attention @@ -453,23 +453,23 @@ typedef struct * @arg DCMI_IT_LINE: Line interrupt mask * @retval The state of INTERRUPT. */ -#define __HAL_DCMI_IT_STATUS(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MISR & (__INTERRUPT__)) +#define __HAL_DCMI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MISR & (__INTERRUPT__)) /* Exported functions --------------------------------------------------------*/ /* Initialization and de-initialization functions *******************************/ HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi); HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi); -__weak void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi); -__weak void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi); +void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi); +void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi); /* IO operation functions *******************************************************/ HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length); HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi); -__weak void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi); -__weak void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi); -__weak void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi); -__weak void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi); +void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi); +void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi); +void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi); +void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi); void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi); /* Peripheral Control functions *************************************************/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h index 3b7c33e23d..78b560aab1 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_def.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_def.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief This file contains HAL common defines, enumeration, macros and * structures definitions. ****************************************************************************** @@ -115,7 +115,30 @@ typedef enum #endif /* __packed */ #endif /* __GNUC__ */ - + +/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ +#if defined (__GNUC__) /* GNU Compiler */ + #ifndef __ALIGN_END + #define __ALIGN_END __attribute__ ((aligned (4))) + #endif /* __ALIGN_END */ + #ifndef __ALIGN_BEGIN + #define __ALIGN_BEGIN + #endif /* __ALIGN_BEGIN */ +#else + #ifndef __ALIGN_END + #define __ALIGN_END + #endif /* __ALIGN_END */ + #ifndef __ALIGN_BEGIN + #if defined (__CC_ARM) /* ARM Compiler */ + #define __ALIGN_BEGIN __align(4) + #elif defined (__ICCARM__) /* IAR Compiler */ + #define __ALIGN_BEGIN + #elif defined (__TASKING__) /* TASKING Compiler */ + #define __ALIGN_BEGIN __align(4) + #endif /* __CC_ARM */ + #endif /* __ALIGN_BEGIN */ +#endif /* __GNUC__ */ + #ifdef __cplusplus } #endif diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c index de0d56c3f7..40e1bbc244 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief DMA HAL module driver. * * This file provides firmware functions to manage the following @@ -77,7 +77,7 @@ (+) __HAL_DMA_CLEAR_FLAG: Clear the DMA Stream pending flags. (+) __HAL_DMA_ENABLE_IT: Enable the specified DMA Stream interrupts. (+) __HAL_DMA_DISABLE_IT: Disable the specified DMA Stream interrupts. - (+) __HAL_DMA_IT_STATUS: Check whether the specified DMA Stream interrupt has occurred or not. + (+) __HAL_DMA_GET_IT_SOURCE: Check whether the specified DMA Stream interrupt has occurred or not. [..] (@) You can refer to the DMA HAL driver header file for more useful macros @@ -301,6 +301,9 @@ HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma) /* Initialize the DMA state */ hdma->State = HAL_DMA_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hdma); + return HAL_OK; } @@ -606,7 +609,7 @@ void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma) /* Transfer Error Interrupt management ***************************************/ if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)) != RESET) { - if(__HAL_DMA_IT_STATUS(hdma, DMA_IT_TE) != RESET) + if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_TE) != RESET) { /* Disable the transfer error interrupt */ __HAL_DMA_DISABLE_IT(hdma, DMA_IT_TE); @@ -633,7 +636,7 @@ void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma) /* FIFO Error Interrupt management ******************************************/ if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)) != RESET) { - if(__HAL_DMA_IT_STATUS(hdma, DMA_IT_FE) != RESET) + if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_FE) != RESET) { /* Disable the FIFO Error interrupt */ __HAL_DMA_DISABLE_IT(hdma, DMA_IT_FE); @@ -660,7 +663,7 @@ void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma) /* Direct Mode Error Interrupt management ***********************************/ if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)) != RESET) { - if(__HAL_DMA_IT_STATUS(hdma, DMA_IT_DME) != RESET) + if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_DME) != RESET) { /* Disable the direct mode Error interrupt */ __HAL_DMA_DISABLE_IT(hdma, DMA_IT_DME); @@ -687,7 +690,7 @@ void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma) /* Half Transfer Complete Interrupt management ******************************/ if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)) != RESET) { - if(__HAL_DMA_IT_STATUS(hdma, DMA_IT_HT) != RESET) + if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_HT) != RESET) { /* Multi_Buffering mode enabled */ if(((hdma->Instance->CR) & (uint32_t)(DMA_SxCR_DBM)) != 0) @@ -733,7 +736,7 @@ void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma) /* Transfer Complete Interrupt management ***********************************/ if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)) != RESET) { - if(__HAL_DMA_IT_STATUS(hdma, DMA_IT_TC) != RESET) + if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_TC) != RESET) { if(((hdma->Instance->CR) & (uint32_t)(DMA_SxCR_DBM)) != 0) { diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h index 144851f5af..d248e4c4e4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of DMA HAL module. ****************************************************************************** * @attention @@ -626,7 +626,7 @@ typedef struct __DMA_HandleTypeDef * @arg DMA_IT_DME: Direct mode error interrupt. * @retval The state of DMA_IT. */ -#define __HAL_DMA_IT_STATUS(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \ +#define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \ ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) : \ ((__HANDLE__)->Instance->FCR & (__INTERRUPT__))) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c index 72f6f67088..f0901020ba 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma2d.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief DMA2D HAL module driver. * This file provides firmware functions to manage the following * functionalities of the DMA2D peripheral: @@ -79,7 +79,7 @@ (+) __HAL_DMA2D_CLEAR_FLAG: Clears the DMA2D pending flags. (+) __HAL_DMA2D_ENABLE_IT: Enables the specified DMA2D interrupts. (+) __HAL_DMA2D_DISABLE_IT: Disables the specified DMA2D interrupts. - (+) __HAL_DMA2D_IT_STATUS: Checks whether the specified DMA2D interrupt has occurred or not. + (+) __HAL_DMA2D_GET_IT_SOURCE: Checks whether the specified DMA2D interrupt has occurred or not. [..] (@) You can refer to the DMA2D HAL driver header file for more useful macros @@ -128,7 +128,7 @@ #ifdef HAL_DMA2D_MODULE_ENABLED -#if defined(STM32F429xx) || defined(STM32F439xx) +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ @@ -265,6 +265,9 @@ HAL_StatusTypeDef HAL_DMA2D_DeInit(DMA2D_HandleTypeDef *hdma2d) /* Initialize the DMA2D state*/ hdma2d->State = HAL_DMA2D_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hdma2d); + return HAL_OK; } @@ -720,7 +723,7 @@ void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d) /* Transfer Error Interrupt management ***************************************/ if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TE) != RESET) { - if(__HAL_DMA2D_IT_STATUS(hdma2d, DMA2D_IT_TE) != RESET) + if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_TE) != RESET) { /* Disable the transfer Error interrupt */ __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TE); @@ -747,7 +750,7 @@ void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d) /* Configuration Error Interrupt management **********************************/ if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CE) != RESET) { - if(__HAL_DMA2D_IT_STATUS(hdma2d, DMA2D_IT_CE) != RESET) + if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_CE) != RESET) { /* Disable the Configuration Error interrupt */ __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CE); @@ -774,7 +777,7 @@ void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d) /* Transfer Complete Interrupt management ************************************/ if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TC) != RESET) { - if(__HAL_DMA2D_IT_STATUS(hdma2d, DMA2D_IT_TC) != RESET) + if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_TC) != RESET) { /* Disable the transfer complete interrupt */ __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TC); @@ -1223,7 +1226,7 @@ static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_ /** * @} */ -#endif /* STM32F429xx || STM32F439xx */ +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ #endif /* HAL_DMA2D_MODULE_ENABLED */ /** * @} diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.h index f309873d20..40db8e70b0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma2d.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma2d.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of DMA2D HAL module. ****************************************************************************** * @attention @@ -43,7 +43,7 @@ extern "C" { #endif -#if defined(STM32F429xx) || defined(STM32F439xx) +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal_def.h" @@ -449,15 +449,15 @@ typedef struct __DMA2D_HandleTypeDef * @arg DMA2D_IT_TE: Transfer error interrupt mask * @retval The state of INTERRUPT. */ -#define __HAL_DMA2D_IT_STATUS(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) +#define __HAL_DMA2D_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) /* Exported functions --------------------------------------------------------*/ /* Initialization and de-initialization functions *******************************/ HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d); HAL_StatusTypeDef HAL_DMA2D_DeInit (DMA2D_HandleTypeDef *hdma2d); -__weak void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d); -__weak void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d); +void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d); +void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d); /* IO operation functions *******************************************************/ HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Heigh); @@ -481,7 +481,7 @@ HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint3 HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d); uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d); -#endif /* STM32F429xx || STM32F439xx */ +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ /** * @} diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.c index 2ac72bf3a1..91a775171d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief DMA Extension HAL module driver * This file provides firmware functions to manage the following * functionalities of the DMA Extension peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.h index aded6877f2..fdaafea401 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_dma_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_dma_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of DMA HAL extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c index bbcd2f9079..eaf2b155e3 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_eth.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief ETH HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Ethernet (ETH) peripheral: @@ -402,7 +402,10 @@ HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth) /* Set ETH HAL state to Disabled */ heth->State= HAL_ETH_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(heth); + /* Return function status */ return HAL_OK; } @@ -882,7 +885,7 @@ void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth) HAL_ETH_RxCpltCallback(heth); /* Clear the Eth DMA Rx IT pending bits */ - __HAL_ETH_DMA_CLEAR_IT_PENDING_BIT(heth, ETH_DMA_IT_R); + __HAL_ETH_DMA_CLEAR_IT(heth, ETH_DMA_IT_R); /* Set HAL State to Ready */ heth->State = HAL_ETH_STATE_READY; @@ -898,7 +901,7 @@ void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth) HAL_ETH_TxCpltCallback(heth); /* Clear the Eth DMA Tx IT pending bits */ - __HAL_ETH_DMA_CLEAR_IT_PENDING_BIT(heth, ETH_DMA_IT_T); + __HAL_ETH_DMA_CLEAR_IT(heth, ETH_DMA_IT_T); /* Set HAL State to Ready */ heth->State = HAL_ETH_STATE_READY; @@ -908,7 +911,7 @@ void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth) } /* Clear the interrupt flags */ - __HAL_ETH_DMA_CLEAR_IT_PENDING_BIT(heth, ETH_DMA_IT_NIS); + __HAL_ETH_DMA_CLEAR_IT(heth, ETH_DMA_IT_NIS); /* ETH DMA Error */ if(__HAL_ETH_DMA_GET_FLAG(heth, ETH_DMA_FLAG_AIS)) @@ -917,7 +920,7 @@ void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth) HAL_ETH_ErrorCallback(heth); /* Clear the interrupt flags */ - __HAL_ETH_DMA_CLEAR_IT_PENDING_BIT(heth, ETH_DMA_FLAG_AIS); + __HAL_ETH_DMA_CLEAR_IT(heth, ETH_DMA_FLAG_AIS); /* Set HAL State to Ready */ heth->State = HAL_ETH_STATE_READY; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h index 55c7f4ff5f..1fa014d081 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_eth.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_eth.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of ETH HAL module. ****************************************************************************** * @attention @@ -1910,7 +1910,7 @@ typedef struct * @param __INTERRUPT__: specifies the interrupt pending bit to clear. @defgroup ETH_DMA_Interrupts * @retval None */ -#define __HAL_ETH_DMA_CLEAR_IT_PENDING_BIT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMASR =(__INTERRUPT__)) +#define __HAL_ETH_DMA_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMASR =(__INTERRUPT__)) /** * @brief Checks whether the specified ETHERNET DMA flag is set or not. @@ -2134,8 +2134,8 @@ typedef struct /* Initialization and de-initialization functions ****************************/ HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth); HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth); -__weak void HAL_ETH_MspInit(ETH_HandleTypeDef *heth); -__weak void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth); +void HAL_ETH_MspInit(ETH_HandleTypeDef *heth); +void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth); HAL_StatusTypeDef HAL_ETH_DMATxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *DMATxDescTab, uint8_t* TxBuff, uint32_t TxBuffCount); HAL_StatusTypeDef HAL_ETH_DMARxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *DMARxDescTab, uint8_t *RxBuff, uint32_t RxBuffCount); @@ -2148,9 +2148,9 @@ HAL_StatusTypeDef HAL_ETH_GetReceivedFrame_IT(ETH_HandleTypeDef *heth); void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth); /* Callback in non blocking modes (Interrupt) */ -__weak void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth); -__weak void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth); -__weak void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth); +void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth); +void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth); +void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth); /* Cmmunication with PHY functions*/ HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t *RegValue); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.c index c75ae1cd74..624fea035d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_flash.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief FLASH HAL module driver. * This file provides firmware functions to manage the following * functionalities of the internal FLASH memory: @@ -281,7 +281,7 @@ void HAL_FLASH_IRQHandler(void) FLASH->CR &= (~FLASH_MER_BIT); /* Check FLASH End of Operation flag */ - if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP)) + if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP) != RESET) { if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE) { @@ -338,7 +338,7 @@ void HAL_FLASH_IRQHandler(void) /* Check FLASH operation error flags */ if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | \ - FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR))) + FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR)) != RESET) { if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE) { @@ -568,7 +568,7 @@ HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout) uint32_t timeout = HAL_GetTick() + Timeout; - while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY)) + while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) != RESET) { if(Timeout != HAL_MAX_DELAY) { @@ -580,7 +580,7 @@ HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout) } if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | \ - FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR))) + FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR)) != RESET) { /*Save the error code*/ FLASH_SetErrorCode(); @@ -700,32 +700,32 @@ static void FLASH_Program_Byte(uint32_t Address, uint8_t Data) */ static void FLASH_SetErrorCode(void) { - if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)) + if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) != RESET) { pFlash.ErrorCode = FLASH_ERROR_WRP; } - if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR)) + if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) != RESET) { pFlash.ErrorCode |= FLASH_ERROR_PGA; } - if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGPERR)) + if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGPERR) != RESET) { pFlash.ErrorCode |= FLASH_ERROR_PGP; } - if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR)) + if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR) != RESET) { pFlash.ErrorCode |= FLASH_ERROR_PGS; } - if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR)) + if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) != RESET) { pFlash.ErrorCode |= FLASH_ERROR_RD; } - if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR)) + if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR) != RESET) { pFlash.ErrorCode |= FLASH_ERROR_OPERATION; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.h index 361f1840a0..a8533c9b20 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_flash.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of FLASH HAL module. ****************************************************************************** * @attention @@ -302,7 +302,7 @@ typedef struct * @arg FLASH_FLAG_BSY : FLASH Busy flag * @retval The new state of __FLAG__ (SET or RESET). */ -#define __HAL_FLASH_GET_FLAG(__FLAG__) ((FLASH->SR & (__FLAG__)) == (__FLAG__)) +#define __HAL_FLASH_GET_FLAG(__FLAG__) ((FLASH->SR & (__FLAG__))) /** * @brief Clear the specified FLASH flag. @@ -329,8 +329,8 @@ HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, /* FLASH IRQ handler method */ void HAL_FLASH_IRQHandler(void); /* Callbacks in non blocking modes */ -__weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); -__weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); +void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); +void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); /* Peripheral Control functions **********************************************/ HAL_StatusTypeDef HAL_FLASH_Unlock(void); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.c index 92ba872acc..5f4b2b6f29 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_flash_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Extended FLASH HAL module driver. * This file provides firmware functions to manage the following * functionalities of the FLASH extension peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.h index 4956cc122d..70659377cb 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_flash_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_flash_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of FLASH HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c index 6cb1d5ba45..65080d7d4e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_gpio.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief GPIO HAL module driver. * This file provides firmware functions to manage the following * functionalities of the General Purpose Input/Output (GPIO) peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h index e1e6530065..ff0dd3c619 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_gpio.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of GPIO HAL module. ****************************************************************************** * @attention @@ -258,7 +258,7 @@ GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState); void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin); -__weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); +void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); /** * @} diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio_ex.h index 32b2914eca..b52791f938 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_gpio_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_gpio_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of GPIO HAL Extension module. ****************************************************************************** * @attention @@ -642,7 +642,7 @@ */ #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ -#define GPIO_AF7_I2S3ext ((uint8_t)0x07) /* I2S3ext_SD Alternate Function mapping */ +#define GPIO_AF7_I2S3ext ((uint8_t)0x07) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection @@ -653,6 +653,9 @@ * @brief AF 9 selection */ #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ +#define GPIO_AF9_I2C2 ((uint8_t)0x09) /* I2C2 Alternate Function mapping */ +#define GPIO_AF9_I2C3 ((uint8_t)0x09) /* I2C3 Alternate Function mapping */ + /** * @brief AF 10 selection @@ -680,6 +683,7 @@ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF5_SPI4) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF8_USART6) || ((AF) == GPIO_AF10_OTG_FS) || \ + ((AF) == GPIO_AF9_I2C2) || ((AF) == GPIO_AF9_I2C3) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF15_EVENTOUT)) #endif /* STM32F401xC || STM32F401xE */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c index 1426c918c9..95d64784f0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief HASH HAL module driver. * This file provides firmware functions to manage the following * functionalities of the HASH peripheral: @@ -219,7 +219,10 @@ HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash) /* Change the HASH state */ hhash->State = HAL_HASH_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hhash); + /* Return function status */ return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h index 23797f67f3..e49d1e0dc0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of HASH HAL module. ****************************************************************************** * @attention @@ -304,11 +304,11 @@ void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash); /* Peripheral State functions ************************************************/ HAL_HASH_STATETypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash); -__weak void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash); -__weak void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash); -__weak void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash); -__weak void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash); -__weak void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash); +void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash); +void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash); +void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash); +void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash); +void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash); #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx */ /** diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.c index b74da73acf..4a64c23606 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief HASH HAL Extension module driver. * This file provides firmware functions to manage the following * functionalities of HASH peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.h index 4c0e910a11..34385971bb 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hash_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hash_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of HASH HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c index 58f9f2b2e4..8ea7000070 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hcd.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief HCD HAL module driver. * This file provides firmware functions to manage the following * functionalities of the USB Peripheral Controller: @@ -88,10 +88,10 @@ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ -static void HAL_HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum); -static void HAL_HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum); -static void HAL_HCD_RXQLVL_IRQHandler (HCD_HandleTypeDef *hhcd); -static void HAL_HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd); +static void HCD_HC_IN_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum); +static void HCD_HC_OUT_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum); +static void HCD_RXQLVL_IRQHandler(HCD_HandleTypeDef *hhcd); +static void HCD_Port_IRQHandler(HCD_HandleTypeDef *hhcd); /* Private functions ---------------------------------------------------------*/ /** @defgroup HCD_Private_Functions @@ -489,16 +489,17 @@ void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd) /* Cleanup HPRT */ USBx_HPRT0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |\ USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG ); - + /* Handle Host Port Interrupts */ HAL_HCD_Disconnect_Callback(hhcd); + USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_48_MHZ ); __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_DISCINT); } /* Handle Host Port Interrupts */ if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_HPRTINT)) { - HAL_HCD_Port_IRQHandler (hhcd); + HCD_Port_IRQHandler (hhcd); } /* Handle Host SOF Interrupts */ @@ -519,11 +520,11 @@ void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd) { if ((USBx_HC(i)->HCCHAR) & USB_OTG_HCCHAR_EPDIR) { - HAL_HCD_HC_IN_IRQHandler (hhcd, i); + HCD_HC_IN_IRQHandler (hhcd, i); } else { - HAL_HCD_HC_OUT_IRQHandler (hhcd, i); + HCD_HC_OUT_IRQHandler (hhcd, i); } } } @@ -535,7 +536,7 @@ void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd) { USB_MASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_RXFLVL); - HAL_HCD_RXQLVL_IRQHandler (hhcd); + HCD_RXQLVL_IRQHandler (hhcd); USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_RXFLVL); } @@ -644,7 +645,6 @@ HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd) { __HAL_LOCK(hhcd); USB_StopHost(hhcd->Instance); - USB_DriveVbus(hhcd->Instance, 0); __HAL_UNLOCK(hhcd); return HAL_OK; } @@ -773,7 +773,7 @@ uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd) * This parameter can be a value from 1 to 15 * @retval none */ -static void HAL_HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) +static void HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) { USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; @@ -912,7 +912,7 @@ static void HAL_HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) * This parameter can be a value from 1 to 15 * @retval none */ -static void HAL_HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) +static void HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) { USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; @@ -1052,7 +1052,7 @@ static void HAL_HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) * @param hhcd: HCD handle * @retval none */ -static void HAL_HCD_RXQLVL_IRQHandler (HCD_HandleTypeDef *hhcd) +static void HCD_RXQLVL_IRQHandler (HCD_HandleTypeDef *hhcd) { USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; uint8_t channelnum =0; @@ -1102,7 +1102,7 @@ static void HAL_HCD_RXQLVL_IRQHandler (HCD_HandleTypeDef *hhcd) * @param hhcd: HCD handle * @retval none */ -static void HAL_HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd) +static void HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd) { USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; __IO uint32_t hprt0, hprt0_dup; @@ -1116,9 +1116,10 @@ static void HAL_HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd) /* Check wether Port Connect Detected */ if((hprt0 & USB_OTG_HPRT_PCDET) == USB_OTG_HPRT_PCDET) - { + { if((hprt0 & USB_OTG_HPRT_PCSTS) == USB_OTG_HPRT_PCSTS) { + USB_MASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT); HAL_HCD_Connect_Callback(hhcd); } hprt0_dup |= USB_OTG_HPRT_PCDET; @@ -1138,17 +1139,33 @@ static void HAL_HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd) { USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_6_MHZ ); } - else if ((hprt0 & USB_OTG_HPRT_PSPD) == (HPRT0_PRTSPD_FULL_SPEED << 17)) + else { USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_48_MHZ ); } } else { - USB_InitFSLSPClkSel(USBx , HCFG_30_60_MHZ); + if(hhcd->Init.speed == HCD_SPEED_FULL) + { + USBx_HOST->HFIR = (uint32_t)60000; + } } HAL_HCD_Connect_Callback(hhcd); + + if(hhcd->Init.speed == HCD_SPEED_HIGH) + { + USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT); + } } + else + { + /* Cleanup HPRT */ + USBx_HPRT0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |\ + USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG ); + + USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT); + } } /* Check For an overcurrent */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h index c4387b842a..a4de060027 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hcd.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of HCD HAL module. ****************************************************************************** * @attention @@ -116,8 +116,9 @@ typedef struct * @{ */ #define HCD_SPEED_HIGH 0 -#define HCD_SPEED_FULL 1 #define HCD_SPEED_LOW 2 +#define HCD_SPEED_FULL 3 + /** * @} */ @@ -174,8 +175,8 @@ HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd, HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, uint8_t ch_num); -__weak void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd); -__weak void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd); +void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd); +void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd); /* I/O operation functions *****************************************************/ HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd, @@ -189,10 +190,10 @@ HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd, /* Non-Blocking mode: Interrupt */ void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd); -__weak void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd); -__weak void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd); -__weak void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd); -__weak void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, +void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd); +void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd); +void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd); +void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c index c25f3436cd..80d92c51e4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2c.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief I2C HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Inter Integrated Circuit (I2C) peripheral: @@ -372,8 +372,12 @@ HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c) HAL_I2C_MspDeInit(hi2c); hi2c->ErrorCode = HAL_I2C_ERROR_NONE; + hi2c->State = HAL_I2C_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hi2c); + return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h index eaf06e3db9..af574dc3bd 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2c.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of I2C HAL module. ****************************************************************************** * @attention @@ -392,8 +392,8 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c); HAL_StatusTypeDef HAL_I2C_DeInit (I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c); +void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c); +void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c); /* I/O operation functions *****************************************************/ /******* Blocking mode: Polling */ @@ -424,13 +424,13 @@ HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddr /******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c); void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c); -__weak void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c); +void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c); +void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c); +void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c); +void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c); +void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c); +void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c); +void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c); /* Peripheral Control and State functions **************************************/ HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.c index daef1e81ae..e6a750461c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2c_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief I2C Extension HAL module driver. * This file provides firmware functions to manage the following * functionalities of I2C extension peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.h index 73a1fcc779..58c75b42f4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2c_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2c_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of I2C HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c index 8b5316b161..1e7b41fc77 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2s.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief I2S HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Integrated Interchip Sound (I2S) peripheral: @@ -392,7 +392,10 @@ HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) HAL_I2S_MspDeInit(hi2s); hi2s->State = HAL_I2S_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hi2s); + return HAL_OK; } @@ -530,7 +533,7 @@ HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uin if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_BSY, SET, Timeout) != HAL_OK) { return HAL_TIMEOUT; - } + } hi2s->State = HAL_I2S_STATE_READY; @@ -1053,10 +1056,17 @@ HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s) I2SxEXT(hi2s->Instance)->CR2 &= (uint32_t)(~SPI_CR2_RXDMAEN); } - /* Disable the I2S DMA Stream */ - __HAL_DMA_DISABLE(hi2s->hdmatx); - __HAL_DMA_DISABLE(hi2s->hdmarx); - + /* Abort the I2S DMA Stream tx */ + if(hi2s->hdmatx != NULL) + { + HAL_DMA_Abort(hi2s->hdmatx); + } + /* Abort the I2S DMA Stream rx */ + if(hi2s->hdmarx != NULL) + { + HAL_DMA_Abort(hi2s->hdmarx); + } + /* Disable I2S peripheral */ __HAL_I2S_DISABLE(hi2s); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h index b4c8207bcf..8ab5057378 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2s.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of I2S HAL module. ****************************************************************************** * @attention @@ -399,11 +399,11 @@ HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s); HAL_I2S_ErrorTypeDef HAL_I2S_GetError(I2S_HandleTypeDef *hi2s); /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/ -__weak void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s); -__weak void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s); -__weak void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s); -__weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s); -__weak void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s); +void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s); +void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s); +void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s); +void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s); +void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s); void I2S_DMATxCplt(DMA_HandleTypeDef *hdma); void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.c index f09ea24112..eb247258ca 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2s_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief I2S HAL module driver. * This file provides firmware functions to manage the following * functionalities of I2S extension peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.h index 45d2940368..c6f39bf8a7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_i2s_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_i2s_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of I2S HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c index 0a7773cb3d..bc0b38481e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_irda.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief IRDA HAL module driver. * This file provides firmware functions to manage the following * functionalities of the IrDA SIR ENDEC block (IrDA): @@ -140,6 +140,7 @@ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ +#define IRDA_TIMEOUT_VALUE 22000 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ @@ -279,9 +280,13 @@ HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda) /* DeInit the low level hardware */ HAL_IRDA_MspDeInit(hirda); - hirda->ErrorCode = HAL_IRDA_ERROR_NONE; + hirda->ErrorCode = HAL_IRDA_ERROR_NONE; + hirda->State = HAL_IRDA_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hirda); + return HAL_OK; } @@ -938,21 +943,33 @@ uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda) * @param hdma : DMA handle * @retval None */ -static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma) +static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma) { IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; - + hirda->TxXferCount = 0; - - if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) + + /* Wait for IRDA TC Flag */ + if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TC, RESET, IRDA_TIMEOUT_VALUE) != HAL_OK) { - hirda->State = HAL_IRDA_STATE_BUSY_RX; + /* Timeout Occured */ + hirda->State = HAL_IRDA_STATE_TIMEOUT; + HAL_IRDA_ErrorCallback(hirda); } else { - hirda->State = HAL_IRDA_STATE_READY; + /* No Timeout */ + /* Check if a receive process is ongoing or not */ + if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) + { + hirda->State = HAL_IRDA_STATE_BUSY_RX; + } + else + { + hirda->State = HAL_IRDA_STATE_READY; + } + HAL_IRDA_TxCpltCallback(hirda); } - HAL_IRDA_TxCpltCallback(hirda); } /** diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h index 71c14c0b61..e15ad994cf 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_irda.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_irda.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of IRDA HAL module. ****************************************************************************** * @attention @@ -348,8 +348,8 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda); HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda); -__weak void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); -__weak void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); +void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); +void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); /* IO operation functions *******************************************************/ HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); @@ -359,9 +359,9 @@ HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda); -__weak void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); -__weak void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); -__weak void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); +void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); +void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); +void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); /* Peripheral State functions **************************************************/ HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c index 278bc0d6e0..391f3a2d44 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_iwdg.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief IWDG HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Independent Watchdog (IWDG) peripheral: @@ -216,18 +216,6 @@ __weak void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg) */ } -/** - * @brief DeInitializes the IWDG MSP. - * @param hiwdg: IWDG handle - * @retval None - */ -__weak void HAL_IWDG_MspDeInit(IWDG_HandleTypeDef *hiwdg) -{ - /* NOTE : This function Should not be modified, when the callback is needed, - the HAL_IWDG_MspDeInit could be implemented in the user file - */ -} - /** * @} */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h index b32ea24f88..a8e0479f54 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_iwdg.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of IWDG HAL module. ****************************************************************************** * @attention @@ -54,7 +54,7 @@ * @{ */ -/* Exported types ------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ /** * @brief IWDG HAL State Structure definition @@ -63,7 +63,7 @@ typedef enum { HAL_IWDG_STATE_RESET = 0x00, /*!< IWDG not yet initialized or disabled */ HAL_IWDG_STATE_READY = 0x01, /*!< IWDG initialized and ready for use */ - HAL_IWDG_STATE_BUSY = 0x02, /*!< IWDG internal process is ongoing */ + HAL_IWDG_STATE_BUSY = 0x02, /*!< IWDG internal process is ongoing */ HAL_IWDG_STATE_TIMEOUT = 0x03, /*!< IWDG timeout state */ HAL_IWDG_STATE_ERROR = 0x04 /*!< IWDG error state */ @@ -78,7 +78,7 @@ typedef struct This parameter can be a value of @ref IWDG_Prescaler */ uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. - This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ + This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ }IWDG_InitTypeDef; @@ -221,16 +221,15 @@ typedef struct /* Exported functions --------------------------------------------------------*/ -/* Initialization/de-initialization functions **********************************/ +/* Initialization/de-initialization functions ********************************/ HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); -__weak void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg); -__weak void HAL_IWDG_MspDeInit(IWDG_HandleTypeDef *hiwdg); +void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg); -/* I/O operation functions ******************************************************/ +/* I/O operation functions ****************************************************/ HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg); HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); -/* Peripheral State functions **************************************************/ +/* Peripheral State functions ************************************************/ HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg); /** diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c index 92c63434ea..d264a8b243 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_ltdc.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief LTDC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the LTDC peripheral: @@ -60,7 +60,7 @@ (+) __HAL_LTDC_CLEAR_FLAG: Clears the LTDC pending flags. (+) __HAL_LTDC_ENABLE_IT: Enables the specified LTDC interrupts. (+) __HAL_LTDC_DISABLE_IT: Disables the specified LTDC interrupts. - (+) __HAL_LTDC_IT_STATUS: Checks whether the specified LTDC interrupt has occurred or not. + (+) __HAL_LTDC_GET_IT_SOURCE: Checks whether the specified LTDC interrupt has occurred or not. [..] (@) You can refer to the LTDC HAL driver header file for more useful macros @@ -247,6 +247,9 @@ HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc) /* Initialize the LTDC state*/ hltdc->State = HAL_LTDC_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hltdc); + return HAL_OK; } @@ -304,7 +307,7 @@ void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc) /* Transfer Error Interrupt management ***************************************/ if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_TE) != RESET) { - if(__HAL_LTDC_IT_STATUS(hltdc, LTDC_IT_TE) != RESET) + if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_TE) != RESET) { /* Disable the transfer Error interrupt */ __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_TE); @@ -328,7 +331,7 @@ void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc) /* FIFO underrun Interrupt management ***************************************/ if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_FU) != RESET) { - if(__HAL_LTDC_IT_STATUS(hltdc, LTDC_IT_FU) != RESET) + if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_FU) != RESET) { /* Disable the FIFO underrun interrupt */ __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_FU); @@ -352,7 +355,7 @@ void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc) /* Line Interrupt management ************************************************/ if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_LI) != RESET) { - if(__HAL_LTDC_IT_STATUS(hltdc, LTDC_IT_LI) != RESET) + if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_LI) != RESET) { /* Disable the Line interrupt */ __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h index de1d46f245..42fbfed67e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_ltdc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_ltdc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of LTDC HAL module. ****************************************************************************** * @attention @@ -524,17 +524,17 @@ typedef struct * @arg LTDC_IT_RR: Register Reload Interrupt Flag * @retval The state of INTERRUPT (SET or RESET). */ -#define __HAL_LTDC_IT_STATUS(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->ISR & (__INTERRUPT__)) +#define __HAL_LTDC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->ISR & (__INTERRUPT__)) /* Exported functions --------------------------------------------------------*/ /* Initialization and de-initialization functions *******************************/ HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc); HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc); -__weak void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc); -__weak void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc); -__weak void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc); -__weak void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc); +void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc); +void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc); +void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc); +void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc); /* IO operation functions *******************************************************/ void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c index a309e7c2ba..c0ef40e29e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_nand.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief NAND HAL module driver. * This file provides a generic firmware to drive NAND memories mounted * as external device. @@ -154,13 +154,12 @@ HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingT FMC_NAND_AttributeSpace_Timing_Init(hnand->Instance, AttSpace_Timing, hnand->Init.NandBank); /* Enable the NAND device */ - __FMC_NAND_ENABLE(hnand->Instance, hnand->Init.NandBank); + __FMC_NAND_ENABLE(hnand->Instance, hnand->Init.NandBank); /* Update the NAND controller state */ - hnand->State = HAL_NAND_STATE_READY; - - return HAL_OK; + hnand->State = HAL_NAND_STATE_READY; + return HAL_OK; } /** @@ -172,12 +171,17 @@ HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand) { /* Initialize the low level hardware (MSP) */ HAL_NAND_MspDeInit(hnand); - + /* Configure the NAND registers with their reset values */ FMC_NAND_DeInit(hnand->Instance, hnand->Init.NandBank); - return HAL_OK; - + /* Reset the NAND controller state */ + hnand->State = HAL_NAND_STATE_RESET; + + /* Release Lock */ + __HAL_UNLOCK(hnand); + + return HAL_OK; } /** diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h index d30842f03b..aa6458331c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nand.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_nand.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of NAND HAL module. ****************************************************************************** * @attention @@ -193,10 +193,10 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingTypeDef *ComSpace_Timing, FMC_NAND_PCC_TimingTypeDef *AttSpace_Timing); HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand); -__weak void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand); -__weak void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand); +void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand); +void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand); void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand); -__weak void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand); +void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand); /* IO operation functions *****************************************************/ HAL_StatusTypeDef HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c index 7df6e8bd52..c1e85f7ac3 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_nor.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief NOR HAL module driver. * This file provides a generic firmware to drive NOR memories mounted * as external device. @@ -94,12 +94,11 @@ * @{ */ #ifdef HAL_NOR_MODULE_ENABLED - #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ @@ -144,7 +143,7 @@ HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDe { /* Initialize the low level hardware (MSP) */ HAL_NOR_MspInit(hnor); - } + } /* Initialize NOR control Interface */ FMC_NORSRAM_Init(hnor->Instance, &(hnor->Init)); @@ -154,15 +153,14 @@ HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDe /* Initialize NOR extended mode timing Interface */ FMC_NORSRAM_Extended_Timing_Init(hnor->Extended, ExtTiming, hnor->Init.NSBank, hnor->Init.ExtendedMode); - + /* Enable the NORSRAM device */ __FMC_NORSRAM_ENABLE(hnor->Instance, hnor->Init.NSBank); - + /* Check the NOR controller state */ hnor->State = HAL_NOR_STATE_READY; return HAL_OK; - } /** @@ -172,9 +170,6 @@ HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDe */ HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor) { - /* Update the NOR controller state */ - hnor->State = HAL_NOR_STATE_BUSY; - /* De-Initialize the low level hardware (MSP) */ HAL_NOR_MspDeInit(hnor); @@ -182,8 +177,11 @@ HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor) FMC_NORSRAM_DeInit(hnor->Instance, hnor->Extended, hnor->Init.NSBank); /* Update the NOR controller state */ - hnor->State = HAL_NOR_STATE_READY; - + hnor->State = HAL_NOR_STATE_RESET; + + /* Release Lock */ + __HAL_UNLOCK(hnor); + return HAL_OK; } @@ -309,7 +307,6 @@ HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor) return HAL_OK; } - /** * @brief Read data from NOR memory * @param hnor: pointer to NOR handle @@ -348,7 +345,6 @@ HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint return HAL_OK; } - /** * @brief Program data to NOR memory * @param hnor: pointer to NOR handle @@ -387,7 +383,6 @@ HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, u return HAL_OK; } - /** * @brief Reads a block of data from the FMC NOR memory. * @param hnor: pointer to NOR handle @@ -433,7 +428,6 @@ HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress return HAL_OK; } - /** * @brief Writes a half-word buffer to the FMC NOR memory. This function * must be used only with S29GL128P NOR memory. @@ -536,7 +530,6 @@ HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAdd } - /** * @brief Erase the entire NOR chip. * @param hnor: pointer to NOR handle @@ -574,7 +567,6 @@ HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address) return HAL_OK; } - /** * @brief Read NOR flash CFI IDs * @param hnor: pointer to NOR handle @@ -613,7 +605,6 @@ HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR return HAL_OK; } - /** * @} */ @@ -624,7 +615,7 @@ HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR @verbatim ============================================================================== ##### NOR Control functions ##### - ============================================================================== + ============================================================================== [..] This subsection provides a set of functions allowing to control dynamically the NOR interface. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h index a7ac7d03cf..5de2e4eb9c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_nor.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_nor.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of NOR HAL module. ****************************************************************************** * @attention @@ -190,16 +190,16 @@ typedef struct * @param __DATA__: Data to write * @retval None */ -#define __NOR_WRITE(__ADDRESS__, __DATA__) (*(__IO uint32_t *)(__ADDRESS__) = (__DATA__)) +#define __NOR_WRITE(__ADDRESS__, __DATA__) (*(__IO uint16_t *)((uint32_t)(__ADDRESS__)) = (__DATA__)) /* Exported functions --------------------------------------------------------*/ /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming); HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor); -__weak void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor); -__weak void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor); -__weak void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout); +void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor); +void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor); +void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout); /* I/O operation functions *****************************************************/ HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.c index 156e46f6ce..99fd7eef13 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pccard.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief PCCARD HAL module driver. * This file provides a generic firmware to drive PCCARD memories mounted * as external device. @@ -86,12 +86,11 @@ * @{ */ #ifdef HAL_PCCARD_MODULE_ENABLED - #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ @@ -169,18 +168,18 @@ HAL_StatusTypeDef HAL_PCCARD_Init(PCCARD_HandleTypeDef *hpccard, FMC_NAND_PCC_Ti */ HAL_StatusTypeDef HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard) { - /* Update the PCCARD controller state */ - hpccard->State = HAL_PCCARD_STATE_BUSY; - /* De-Initialize the low level hardware (MSP) */ - HAL_PCCARD_MspDeInit(hpccard); + HAL_PCCARD_MspDeInit(hpccard); /* Configure the PCCARD registers with their reset values */ FMC_PCCARD_DeInit(hpccard->Instance); /* Update the PCCARD controller state */ hpccard->State = HAL_PCCARD_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hpccard); + return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.h index e8b6c12722..759393c05d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pccard.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pccard.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of PCCARD HAL module. ****************************************************************************** * @attention @@ -143,8 +143,8 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_PCCARD_Init(PCCARD_HandleTypeDef *hpccard, FMC_NAND_PCC_TimingTypeDef *ComSpaceTiming, FMC_NAND_PCC_TimingTypeDef *AttSpaceTiming, FMC_NAND_PCC_TimingTypeDef *IOSpaceTiming); HAL_StatusTypeDef HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard); -__weak void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard); -__weak void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard); +void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard); +void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard); /* IO operation functions *****************************************************/ HAL_StatusTypeDef HAL_CF_Read_ID(PCCARD_HandleTypeDef *hpccard, uint8_t CompactFlash_ID[], uint8_t *pStatus); @@ -153,7 +153,7 @@ HAL_StatusTypeDef HAL_CF_Read_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *p HAL_StatusTypeDef HAL_CF_Erase_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t SectorAddress, uint8_t *pStatus); HAL_StatusTypeDef HAL_CF_Reset(PCCARD_HandleTypeDef *hpccard); void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard); -__weak void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard); +void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard); /* PCCARD State functions *******************************************************/ HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState(PCCARD_HandleTypeDef *hpccard); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c index b5f282ba0e..7a72f2f0ab 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pcd.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief PCD HAL module driver. * This file provides firmware functions to manage the following * functionalities of the USB Peripheral Controller: @@ -177,11 +177,9 @@ HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd) /* Init Device */ USB_DevInit(hpcd->Instance, hpcd->Init); - /* Enable the Interrupts */ - __HAL_PCD_ENABLE(hpcd); - hpcd->State= PCD_READY; + USB_DevDisconnect (hpcd->Instance); return HAL_OK; } @@ -200,6 +198,9 @@ HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd) hpcd->State = PCD_BUSY; + /* Stop Device */ + HAL_PCD_Stop(hpcd); + /* DeInit the low level hardware */ HAL_PCD_MspDeInit(hpcd); @@ -413,8 +414,6 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) } if(( epint & USB_OTG_DIEPINT_TXFE) == USB_OTG_DIEPINT_TXFE) { - fifoemptymsk = 0x1 << epnum; - USBx_DEVICE->DIEPEMPMSK &= ~fifoemptymsk; PCD_WriteEmptyTxFifo(hpcd , epnum); } } @@ -423,33 +422,9 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) } } - /* Handle Suspend Interrupt */ - if(__HAL_GET_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP)) - { - - HAL_PCD_SuspendCallback(hpcd); - - if( (hpcd->Init.low_power_enable) && \ - ( (USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS) == USB_OTG_DSTS_SUSPSTS)) - { - /* un-gate USB Core clock */ - USBx_PCGCCTL |= (USB_OTG_PCGCCTL_STOPCLK | USB_OTG_PCGCCTL_GATECLK); - - /* Request to enter Sleep mode after exit from current ISR */ - SCB->SCR |= (SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk); - } - __HAL_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP); - } - /* Handle Resume Interrupt */ if(__HAL_GET_FLAG(hpcd, USB_OTG_GINTSTS_WKUINT)) - { - if( hpcd->Init.low_power_enable) - { - /* un-gate USB Core clock */ - USBx_PCGCCTL &= ~(USB_OTG_PCGCCTL_STOPCLK | USB_OTG_PCGCCTL_GATECLK); - } - + { /* Clear the Remote Wake-up Signaling */ USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_RWUSIG; @@ -457,6 +432,20 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) __HAL_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_WKUINT); } + + /* Handle Suspend Interrupt */ + if(__HAL_GET_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP)) + { + + if((USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS) == USB_OTG_DSTS_SUSPSTS) + { + + HAL_PCD_SuspendCallback(hpcd); + } + __HAL_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP); + } + + /* Handle Reset Interrupt */ if(__HAL_GET_FLAG(hpcd, USB_OTG_GINTSTS_USBRST)) @@ -488,8 +477,6 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) /* setup EP0 to receive SETUP packets */ USB_EP0_OutStart(hpcd->Instance, hpcd->Init.dma_enable, (uint8_t *)hpcd->Setup); - - HAL_PCD_ResetCallback(hpcd); __HAL_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBRST); } @@ -512,6 +499,9 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) hpcd->Init.ep0_mps = USB_OTG_FS_MAX_PACKET_SIZE ; hpcd->Instance->GUSBCFG |= (USB_OTG_GUSBCFG_TRDT_0 | USB_OTG_GUSBCFG_TRDT_2); } + + HAL_PCD_ResetCallback(hpcd); + __HAL_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_ENUMDNE); } @@ -641,6 +631,7 @@ void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) */ } + /** * @brief Suspend event callbacks * @param hpcd: PCD handle @@ -1054,17 +1045,27 @@ HAL_StatusTypeDef HAL_PCD_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint1 Tx_Offset = hpcd->Instance->GRXFSIZ; - for (i = 0; i < fifo; i++) + if(fifo == 0) { - Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16); + hpcd->Instance->DIEPTXF0_HNPTXFSIZ = (size << 16) | Tx_Offset; + } + else + { + Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16; + for (i = 0; i < (fifo - 1); i++) + { + Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16); + } + + /* Multiply Tx_Size by 2 to get higher performance */ + hpcd->Instance->DIEPTXF[fifo - 1] = (size << 16) | Tx_Offset; + } - - /* Multiply Tx_Size by 2 to get higher performance */ - hpcd->Instance->DIEPTXF[fifo] = (size << 16) | Tx_Offset; return HAL_OK; } + /** * @brief Update FIFO configuration * @param hpcd: PCD handle @@ -1078,6 +1079,37 @@ HAL_StatusTypeDef HAL_PCD_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) return HAL_OK; } + +/** + * @brief HAL_PCD_ActiveRemoteWakeup : active remote wakeup signalling + * @param hpcd: PCD handle + * @retval status + */ +HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup(PCD_HandleTypeDef *hpcd) +{ + USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; + + if((USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS) == USB_OTG_DSTS_SUSPSTS) + { + /* active Remote wakeup signaling */ + USBx_DEVICE->DCTL |= USB_OTG_DCTL_RWUSIG; + } + return HAL_OK; +} + +/** + * @brief HAL_PCD_DeActiveRemoteWakeup : de-active remote wakeup signalling + * @param hpcd: PCD handle + * @retval status + */ +HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup(PCD_HandleTypeDef *hpcd) +{ + USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; + + /* active Remote wakeup signaling */ + USBx_DEVICE->DCTL &= ~(USB_OTG_DCTL_RWUSIG); + return HAL_OK; +} /** * @} */ @@ -1120,9 +1152,10 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t { USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; USB_OTG_EPTypeDef *ep; - uint32_t len = 0; + int32_t len = 0; uint32_t len32b; - + uint32_t fifoemptymsk = 0; + ep = &hpcd->IN_ep[epnum]; len = ep->xfer_len - ep->xfer_count; @@ -1131,6 +1164,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t len = ep->maxpacket; } + len32b = (len + 3) / 4; while ( (USBx_INEP(epnum)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV) > len32b && @@ -1152,6 +1186,13 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t ep->xfer_count += len; } + if(len <= 0) + { + fifoemptymsk = 0x1 << epnum; + USBx_DEVICE->DIEPEMPMSK &= ~fifoemptymsk; + + } + return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h index c60a187efe..02c8973433 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pcd.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pcd.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of PCD HAL module. ****************************************************************************** * @attention @@ -98,8 +98,7 @@ typedef struct */ #define PCD_SPEED_HIGH 0 #define PCD_SPEED_HIGH_IN_FULL 1 -#define PCD_SPEED_LOW 2 -#define PCD_SPEED_FULL 3 +#define PCD_SPEED_FULL 2 /** * @} */ @@ -142,7 +141,68 @@ typedef struct #define __HAL_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__)) #define __HAL_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) |= (__INTERRUPT__)) -#define __HAL_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0) +#define __HAL_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0) + + +#define __HAL_PCD_UNGATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) &= \ + ~(USB_OTG_PCGCCTL_STOPCLK) + + +#define __HAL_PCD_GATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) |= USB_OTG_PCGCCTL_STOPCLK + +#define __HAL_PCD_IS_PHY_SUSPENDED(__HANDLE__) ((*(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE))&0x10) + +#define USB_FS_EXTI_TRIGGER_RISING_EDGE ((uint32_t)0x08) +#define USB_FS_EXTI_TRIGGER_FALLING_EDGE ((uint32_t)0x0C) +#define USB_FS_EXTI_TRIGGER_BOTH_EDGE ((uint32_t)0x10) + +#define USB_HS_EXTI_TRIGGER_RISING_EDGE ((uint32_t)0x08) +#define USB_HS_EXTI_TRIGGER_FALLING_EDGE ((uint32_t)0x0C) +#define USB_HS_EXTI_TRIGGER_BOTH_EDGE ((uint32_t)0x10) + + +#define USB_HS_EXTI_LINE_WAKEUP ((uint32_t)0x00100000) /*!< External interrupt line 20 Connected to the USB HS EXTI Line */ +#define USB_FS_EXTI_LINE_WAKEUP ((uint32_t)0x00040000) /*!< External interrupt line 18 Connected to the USB FS EXTI Line */ + + + +#define __HAL_USB_HS_EXTI_ENABLE_IT() EXTI->IMR |= (USB_HS_EXTI_LINE_WAKEUP) +#define __HAL_USB_HS_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_HS_EXTI_LINE_WAKEUP) +#define __HAL_USB_HS_EXTI_GET_FLAG() EXTI->PR & (USB_HS_EXTI_LINE_WAKEUP) +#define __HAL_USB_HS_EXTI_CLEAR_FLAG() EXTI->PR = (USB_HS_EXTI_LINE_WAKEUP) + +#define __HAL_USB_HS_EXTI_SET_RISING_EGDE_TRIGGER() EXTI->FTSR &= ~(USB_HS_EXTI_LINE_WAKEUP);\ + EXTI->RTSR |= USB_HS_EXTI_LINE_WAKEUP + + +#define __HAL_USB_HS_EXTI_SET_FALLING_EGDE_TRIGGER() EXTI->FTSR |= (USB_HS_EXTI_LINE_WAKEUP);\ + EXTI->RTSR &= ~(USB_HS_EXTI_LINE_WAKEUP) + + +#define __HAL_USB_HS_EXTI_SET_FALLINGRISING_TRIGGER() EXTI->RTSR &= ~(USB_HS_EXTI_LINE_WAKEUP);\ + EXTI->FTSR &= ~(USB_HS_EXTI_LINE_WAKEUP;)\ + EXTI->RTSR |= USB_HS_EXTI_LINE_WAKEUP;\ + EXTI->FTSR |= USB_HS_EXTI_LINE_WAKEUP + + +#define __HAL_USB_FS_EXTI_ENABLE_IT() EXTI->IMR |= USB_FS_EXTI_LINE_WAKEUP +#define __HAL_USB_FS_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_FS_EXTI_LINE_WAKEUP) +#define __HAL_USB_FS_EXTI_GET_FLAG() EXTI->PR & (USB_FS_EXTI_LINE_WAKEUP) +#define __HAL_USB_FS_EXTI_CLEAR_FLAG() EXTI->PR = USB_FS_EXTI_LINE_WAKEUP + +#define __HAL_USB_FS_EXTI_SET_RISING_EGDE_TRIGGER() EXTI->FTSR &= ~(USB_FS_EXTI_LINE_WAKEUP);\ + EXTI->RTSR |= USB_FS_EXTI_LINE_WAKEUP + + +#define __HAL_USB_FS_EXTI_SET_FALLING_EGDE_TRIGGER() EXTI->FTSR |= (USB_FS_EXTI_LINE_WAKEUP);\ + EXTI->RTSR &= ~(USB_FS_EXTI_LINE_WAKEUP) + + +#define __HAL_USB_FS_EXTI_SET_FALLINGRISING_TRIGGER() EXTI->RTSR &= ~(USB_FS_EXTI_LINE_WAKEUP);\ + EXTI->FTSR &= ~(USB_FS_EXTI_LINE_WAKEUP);\ + EXTI->RTSR |= USB_FS_EXTI_LINE_WAKEUP;\ + EXTI->FTSR |= USB_FS_EXTI_LINE_WAKEUP + /** * @} */ @@ -161,17 +221,19 @@ HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd); HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd); void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd); -__weak void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); -__weak void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); -__weak void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd); -__weak void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd); -__weak void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd); -__weak void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd); -__weak void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd); -__weak void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); -__weak void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); -__weak void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd); -__weak void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd); +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd); +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd); +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd); +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd); +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd); +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd); +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd); + + /* Peripheral Control functions ************************************************/ HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd); @@ -187,7 +249,8 @@ HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); HAL_StatusTypeDef HAL_PCD_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); HAL_StatusTypeDef HAL_PCD_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); - +HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup(PCD_HandleTypeDef *hpcd); +HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup(PCD_HandleTypeDef *hpcd); /* Peripheral State functions **************************************************/ PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c index 1d25146080..7577942add 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pwr.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief PWR HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Power Controller (PWR) peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h index c887a782f0..350de24e4a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pwr.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of PWR HAL module. ****************************************************************************** * @attention @@ -312,7 +312,7 @@ void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); void HAL_PWR_EnterSTANDBYMode(void); void HAL_PWR_PVD_IRQHandler(void); -__weak void HAL_PWR_PVDCallback(void); +void HAL_PWR_PVDCallback(void); /** diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.c index fcc4a43823..36556ce779 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pwr_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Extended PWR HAL module driver. * This file provides firmware functions to manage the following * functionalities of PWR extension peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.h index 3ab8bd5ee5..57362779e5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_pwr_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_pwr_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of PWR HAL Extension module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c index 67f077b124..a1e82d30fd 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rcc.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief RCC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Reset and Clock Control (RCC) peripheral: @@ -85,7 +85,6 @@ #define HSE_TIMEOUT_VALUE HSE_STARTUP_TIMEOUT #define HSI_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */ #define LSI_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */ -#define LSE_TIMEOUT_VALUE ((uint32_t)5000) /* 5 s */ #define PLL_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */ #define CLOCKSWITCH_TIMEOUT_VALUE ((uint32_t)5000) /* 5 s */ @@ -476,15 +475,23 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) /* Check the parameters */ assert_param(IS_RCC_LSE(RCC_OscInitStruct->LSEState)); - /* Check the LSE State before enabling the access to the Bachup domain */ - if((RCC_OscInitStruct->LSEState) != RCC_LSE_OFF) + /* Enable Power Clock*/ + __PWR_CLK_ENABLE(); + + /* Enable write access to Backup domain */ + PWR->CR |= PWR_CR_DBP; + + /* Wait for Backup domain Write protection disable */ + timeout = HAL_GetTick() + DBP_TIMEOUT_VALUE; + + while((PWR->CR & PWR_CR_DBP) == RESET) { - /* Enable Power Controller clock */ - __PWR_CLK_ENABLE(); - - /* Enable write access to Backup domain */ - PWR->CR |= PWR_CR_DBP; + if(HAL_GetTick() >= timeout) + { + return HAL_TIMEOUT; + } } + /* Reset LSEON and LSEBYP bits before configuring the LSE ----------------*/ __HAL_RCC_LSE_CONFIG(RCC_LSE_OFF); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h index 3f00de5764..02b254d5dc 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rcc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of RCC HAL module. ****************************************************************************** * @attention @@ -186,8 +186,11 @@ typedef struct #define CIR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + 0x0C + 0x02)) /* BDCR register base address */ -#define BDCR_BYTE0_ADDRESS (PERIPH_BASE + RCC_BDCR_OFFSET) +#define BDCR_BYTE0_ADDRESS (PERIPH_BASE + RCC_BDCR_OFFSET) + +#define DBP_TIMEOUT_VALUE ((uint32_t)100) +#define LSE_TIMEOUT_VALUE ((uint32_t)5000) /** * @} */ @@ -195,6 +198,7 @@ typedef struct /** @defgroup RCC_Oscillator_Type * @{ */ +#define RCC_OSCILLATORTYPE_NONE ((uint32_t)0x00000000) #define RCC_OSCILLATORTYPE_HSE ((uint32_t)0x00000001) #define RCC_OSCILLATORTYPE_HSI ((uint32_t)0x00000002) #define RCC_OSCILLATORTYPE_LSE ((uint32_t)0x00000004) @@ -934,8 +938,8 @@ typedef struct * RTC clock source). */ #define __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__) (((__RTCCLKSource__) & RCC_BDCR_RTCSEL) == RCC_BDCR_RTCSEL) ? \ - MODIFY_REG(RCC->CFGR, RCC_CFGR_RTCPRE, ((__RTCCLKSource__) & 0xFFFFCFF)) : 0 - + MODIFY_REG(RCC->CFGR, RCC_CFGR_RTCPRE, ((__RTCCLKSource__) & 0xFFFFCFF)) : CLEAR_BIT(RCC->CFGR, RCC_CFGR_RTCPRE) + #define __HAL_RCC_RTC_CONFIG(__RTCCLKSource__) do { __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__); \ RCC->BDCR |= ((__RTCCLKSource__) & 0x00000FFF); \ } while (0) @@ -1100,7 +1104,7 @@ typedef struct /** @brief Set RMVF bit to clear the reset flags: RCC_FLAG_PINRST, RCC_FLAG_PORRST, * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST. */ -#define __HAL_RCC_CLEAR_FLAG() (RCC->CSR |= RCC_CSR_RMVF) +#define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF) /** @brief Check RCC flag is set or not. * @param __FLAG__: specifies the flag to check. @@ -1154,7 +1158,7 @@ void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t void HAL_RCC_NMI_IRQHandler(void); /* User Callbacks in non blocking mode (IT mode) */ -__weak void HAL_RCC_CCSCallback(void); +void HAL_RCC_CCSCallback(void); /** * @} diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.c index 67a17a409e..c6808c35d0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rcc_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Extension RCC HAL module driver. * This file provides firmware functions to manage the following * functionalities RCC extension peripheral: @@ -76,16 +76,28 @@ [..] This subsection provides a set of functions allowing to control the RCC Clocks frequencies. + [..] + (@) Important note: Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to + select the RTC clock source; in this case the Backup domain will be reset in + order to modify the RTC Clock source, as consequence RTC registers (including + the backup registers) and RCC_BDCR register are set to their reset values. @endverbatim * @{ */ #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) /** - * @brief Initializes the RCC extended peripherals clocks according to the specified parameters in the - * RCC_PeriphCLKInitTypeDef. + * @brief Initializes the RCC extended peripherals clocks according to the specified + * parameters in the RCC_PeriphCLKInitTypeDef. * @param PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that - * contains the configuration information for the Extended Peripherals clocks(I2S, SAI, LTDC RTC and TIM clocks). + * contains the configuration information for the Extended Peripherals + * clocks(I2S, SAI, LTDC RTC and TIM). + * + * @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select + * the RTC clock source; in this case the Backup domain will be reset in + * order to modify the RTC Clock source, as consequence RTC registers (including + * the backup registers) and RCC_BDCR register are set to their reset values. + * * @retval HAL status */ HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit) @@ -246,7 +258,51 @@ HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClk /*---------------------------- RTC configuration -------------------------------*/ if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == (RCC_PERIPHCLK_RTC)) { - __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection); + /* Enable Power Clock*/ + __PWR_CLK_ENABLE(); + + /* Enable write access to Backup domain */ + PWR->CR |= PWR_CR_DBP; + + /* Wait for Backup domain Write protection disable */ + timeout = HAL_GetTick() + DBP_TIMEOUT_VALUE; + + while((PWR->CR & PWR_CR_DBP) == RESET) + { + if(HAL_GetTick() >= timeout) + { + return HAL_TIMEOUT; + } + } + + /* Reset the Backup domain only if the RTC Clock source selction is modified */ + if((RCC->BDCR & RCC_BDCR_RTCSEL) != (PeriphClkInit->RTCClockSelection & RCC_BDCR_RTCSEL)) + { + /* Store the content of BDCR register before the reset of Backup Domain */ + tmpreg = (RCC->BDCR & ~(RCC_BDCR_RTCSEL)); + /* RTC Clock selection can be changed only if the Backup Domain is reset */ + __HAL_RCC_BACKUPRESET_FORCE(); + __HAL_RCC_BACKUPRESET_RELEASE(); + /* Restore the Content of BDCR register */ + RCC->BDCR = tmpreg; + } + + /* If LSE is selected as RTC clock source, wait for LSE reactivation */ + if(PeriphClkInit->RTCClockSelection == RCC_RTCCLKSOURCE_LSE) + { + /* Get timeout */ + timeout = HAL_GetTick() + LSE_TIMEOUT_VALUE; + + /* Wait till LSE is ready */ + while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) + { + if(HAL_GetTick() >= timeout) + { + return HAL_TIMEOUT; + } + } + } + __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection); } /*---------------------------- TIM configuration -------------------------------*/ @@ -304,11 +360,17 @@ void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit) * RCC_PeriphCLKInitTypeDef. * @param PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that * contains the configuration information for the Extended Peripherals clocks(I2S and RTC clocks). + * + * @note A caution to be taken when HAL_RCCEx_PeriphCLKConfig() is used to select RTC clock selection, in this case + * the Reset of Backup domain will be applied in order to modify the RTC Clock source as consequence all backup + * domain (RTC and RCC_BDCR register expect BKPSRAM) will be reset + * * @retval HAL status */ HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit) { uint32_t timeout = 0; + uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_RCC_PERIPHCLOCK(PeriphClkInit->PeriphClockSelection)); @@ -356,7 +418,51 @@ HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClk /*---------------------------- RTC configuration -------------------------------*/ if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == (RCC_PERIPHCLK_RTC)) { - __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection); + /* Enable Power Clock*/ + __PWR_CLK_ENABLE(); + + /* Enable write access to Backup domain */ + PWR->CR |= PWR_CR_DBP; + + /* Wait for Backup domain Write protection disable */ + timeout = HAL_GetTick() + DBP_TIMEOUT_VALUE; + + while((PWR->CR & PWR_CR_DBP) == RESET) + { + if(HAL_GetTick() >= timeout) + { + return HAL_TIMEOUT; + } + } + + /* Reset the Backup domain only if the RTC Clock source selction is modified */ + if((RCC->BDCR & RCC_BDCR_RTCSEL) != (PeriphClkInit->RTCClockSelection & RCC_BDCR_RTCSEL)) + { + /* Store the content of BDCR register before the reset of Backup Domain */ + tmpreg = (RCC->BDCR & ~(RCC_BDCR_RTCSEL)); + /* RTC Clock selection can be changed only if the Backup Domain is reset */ + __HAL_RCC_BACKUPRESET_FORCE(); + __HAL_RCC_BACKUPRESET_RELEASE(); + /* Restore the Content of BDCR register */ + RCC->BDCR = tmpreg; + } + + /* If LSE is selected as RTC clock source, wait for LSE reactivation */ + if(PeriphClkInit->RTCClockSelection == RCC_RTCCLKSOURCE_LSE) + { + /* Get timeout */ + timeout = HAL_GetTick() + LSE_TIMEOUT_VALUE; + + /* Wait till LSE is ready */ + while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) + { + if(HAL_GetTick() >= timeout) + { + return HAL_TIMEOUT; + } + } + } + __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection); } return HAL_OK; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.h index cd37550fc4..2e06c34fda 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rcc_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rcc_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of RCC HAL Extension module. ****************************************************************************** * @attention @@ -154,7 +154,7 @@ typedef struct RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */ - uint8_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection + uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection This parameter can be a value of @ref RCC_RTC_Clock_Source */ }RCC_PeriphCLKInitTypeDef; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c index eff3babdcd..7e40104426 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rng.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief RNG HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Random Number Generator (RNG) peripheral: @@ -118,9 +118,6 @@ HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng) /* Init the low level hardware */ HAL_RNG_MspInit(hrng); } - - /* Change RNG peripheral state */ - hrng->State = HAL_RNG_STATE_BUSY; /* Enable the RNG Peripheral */ __HAL_RNG_ENABLE(hrng); @@ -132,7 +129,6 @@ HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng) return HAL_OK; } - /** * @brief DeInitializes the RNG peripheral. * @param hrng: RNG handle @@ -160,10 +156,13 @@ HAL_StatusTypeDef HAL_RNG_DeInit(RNG_HandleTypeDef *hrng) /* DeInit the low level hardware */ HAL_RNG_MspDeInit(hrng); - /* Update the RNG state */ + /* Update the RNG state */ hrng->State = HAL_RNG_STATE_RESET; - /* Return the function status */ + /* Release Lock */ + __HAL_UNLOCK(hrng); + + /* Return the function status */ return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h index 715f4292b4..38bd68e241 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rng.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rng.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of RNG HAL module. ****************************************************************************** * @attention @@ -182,15 +182,15 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng); HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng); -__weak void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng); -__weak void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng); +void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng); +void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng); /* Peripheral Control functions ************************************************/ uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng); uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng); void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng); -__weak void HAL_RNG_ReadyCallback(RNG_HandleTypeDef* hrng); -__weak void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng); +void HAL_RNG_ReadyCallback(RNG_HandleTypeDef* hrng); +void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng); /* Peripheral State functions **************************************************/ HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c index 31fe3a4689..a28a883f7f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rtc.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief RTC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Real Time Clock (RTC) peripheral: @@ -151,18 +151,6 @@ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ -/* Masks Definition */ -#define RTC_TR_RESERVED_MASK ((uint32_t)0x007F7F7F) -#define RTC_DR_RESERVED_MASK ((uint32_t)0x00FFFF3F) -#define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF) -#define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F) -#define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \ - RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \ - RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \ - RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F | \ - RTC_FLAG_RECALPF | RTC_FLAG_SHPF)) - -#define RTC_TIMEOUT_VALUE 1000 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ @@ -334,7 +322,7 @@ HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc) hrtc->Instance->WUTR = (uint32_t)0x0000FFFF; hrtc->Instance->PRER = (uint32_t)0x007F00FF; hrtc->Instance->CALIBR = (uint32_t)0x00000000; - hrtc->Instance->ALRMAR = (uint32_t)0x00000000; + hrtc->Instance->ALRMAR = (uint32_t)0x00000000; hrtc->Instance->ALRMBR = (uint32_t)0x00000000; hrtc->Instance->SHIFTR = (uint32_t)0x00000000; hrtc->Instance->CALR = (uint32_t)0x00000000; @@ -363,13 +351,16 @@ HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc) } /* Enable the write protection for RTC registers */ - __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); + __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); /* De-Initialize RTC MSP */ HAL_RTC_MspDeInit(hrtc); hrtc->State = HAL_RTC_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hrtc); + return HAL_OK; } @@ -1030,7 +1021,10 @@ HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef { /* Disable the Alarm A interrupt */ __HAL_RTC_ALARMA_DISABLE(hrtc); - + + /* Clear flag alarm A */ + __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRAF); + timeout = HAL_GetTick() + RTC_TIMEOUT_VALUE; /* Wait till RTC ALRAWF flag is set and if Time out is reached exit */ while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == RESET) @@ -1061,7 +1055,10 @@ HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef { /* Disable the Alarm B interrupt */ __HAL_RTC_ALARMB_DISABLE(hrtc); - + + /* Clear flag alarm B */ + __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRBF); + timeout = HAL_GetTick() + RTC_TIMEOUT_VALUE; /* Wait till RTC ALRBWF flag is set and if Time out is reached exit */ while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == RESET) diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h index d831fef1e4..413f6860eb 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rtc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of RTC HAL module. ****************************************************************************** * @attention @@ -694,8 +694,8 @@ typedef struct /* Initialization and de-initialization functions ****************************/ HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); -__weak void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); -__weak void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); +void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); +void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); /* RTC Time and Date functions ************************************************/ HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); @@ -710,7 +710,7 @@ HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alar HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); -__weak void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); +void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); /* Peripheral Control functions ***********************************************/ HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.c index 6c19ef5910..4e68a5c235 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rtc_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief RTC HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Real Time Clock (RTC) Extension peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.h index c5a8d49ccb..df35db3b44 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_rtc_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_rtc_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of RTC HAL Extension module. ****************************************************************************** * @attention @@ -638,9 +638,9 @@ HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperType HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper); void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc); -__weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); -__weak void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); -__weak void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); +void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); +void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); +void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); @@ -651,7 +651,7 @@ HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc); uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc); void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc); -__weak void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); +void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); /* Extension Control functions ************************************************/ @@ -670,7 +670,7 @@ HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc); /* Extension RTC features functions *******************************************/ -__weak void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); +void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c index 6aa92688d9..b2912e3c6f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sai.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief SAI HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Serial Audio Interface (SAI) peripheral: @@ -440,14 +440,14 @@ HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai) /*Set MCKDIV value in CR1 register*/ hsai->Instance->CR1 |= (tmpclock << 20); - } + } /* Initialise the error code */ hsai->ErrorCode = HAL_SAI_ERROR_NONE; - + /* Initialize the SAI state */ hsai->State= HAL_SAI_STATE_READY; - + return HAL_OK; } @@ -463,9 +463,9 @@ HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai) { return HAL_ERROR; } - + hsai->State = HAL_SAI_STATE_BUSY; - + /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */ HAL_SAI_MspDeInit(hsai); @@ -474,7 +474,10 @@ HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai) /* Initialize the SAI state */ hsai->State = HAL_SAI_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(hsai); + return HAL_OK; } @@ -910,10 +913,17 @@ HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai) /* Disable the SAI DMA request */ hsai->Instance->CR1 &= ~SAI_xCR1_DMAEN; - /* Disable the SAI DMA Stream */ - __HAL_DMA_DISABLE(hsai->hdmatx); - __HAL_DMA_DISABLE(hsai->hdmarx); - + /* Abort the SAI DMA Tx Stream */ + if(hsai->hdmatx != NULL) + { + HAL_DMA_Abort(hsai->hdmatx); + } + /* Abort the SAI DMA Rx Stream */ + if(hsai->hdmarx != NULL) + { + HAL_DMA_Abort(hsai->hdmarx); + } + /* Disable SAI peripheral */ __HAL_SAI_DISABLE(hsai); @@ -1219,19 +1229,37 @@ uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai) */ static void SAI_DMATxCplt(DMA_HandleTypeDef *hdma) { + uint32_t timeout = 0x00; + SAI_HandleTypeDef* hsai = (SAI_HandleTypeDef*)((DMA_HandleTypeDef* )hdma)->Parent; - - hsai->TxXferCount = 0; - hsai->RxXferCount = 0; - - /* Disable SAI Tx DMA Request */ - hsai->Instance->CR1 &= (uint32_t)(~SAI_xCR1_DMAEN); - - /* Flush Fifo*/ - hsai->Instance->CR2 |= SAI_xCR2_FFLUSH; - - hsai->State= HAL_SAI_STATE_READY; - + + if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0) + { + hsai->TxXferCount = 0; + hsai->RxXferCount = 0; + + /* Disable SAI Tx DMA Request */ + hsai->Instance->CR1 &= (uint32_t)(~SAI_xCR1_DMAEN); + + /* Set timeout: 10 is the max delay to send the remaining data in the SAI FIFO */ + timeout = HAL_GetTick() + 10; + + /* Wait until FIFO is empty */ + while(__HAL_SAI_GET_FLAG(hsai, SAI_xSR_FLVL) != RESET) + { + /* Check for the Timeout */ + if(HAL_GetTick() >= timeout) + { + /* Update error code */ + hsai->ErrorCode |= HAL_SAI_ERROR_TIMEOUT; + + /* Change the SAI state */ + HAL_SAI_ErrorCallback(hsai); + } + } + + hsai->State= HAL_SAI_STATE_READY; + } HAL_SAI_TxCpltCallback(hsai); } @@ -1255,12 +1283,14 @@ static void SAI_DMATxHalfCplt(DMA_HandleTypeDef *hdma) static void SAI_DMARxCplt(DMA_HandleTypeDef *hdma) { SAI_HandleTypeDef* hsai = ( SAI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; - - /* Disable Rx DMA Request */ - hsai->Instance->CR1 &= (uint32_t)(~SAI_xCR1_DMAEN); - hsai->RxXferCount = 0; - - hsai->State = HAL_SAI_STATE_READY; + if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0) + { + /* Disable Rx DMA Request */ + hsai->Instance->CR1 &= (uint32_t)(~SAI_xCR1_DMAEN); + hsai->RxXferCount = 0; + + hsai->State = HAL_SAI_STATE_READY; + } HAL_SAI_RxCpltCallback(hsai); } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h index f73ac6f99c..876568a1a9 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sai.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sai.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of SAI HAL module. ****************************************************************************** * @attention @@ -735,11 +735,11 @@ HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai); /* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai); -__weak void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai); -__weak void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai); -__weak void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai); -__weak void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai); -__weak void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai); +void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai); +void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai); +void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai); +void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai); +void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai); /* Peripheral State functions **************************************************/ HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c index 08e71fc485..f16ecfdf51 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sd.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief SD card HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Secure Digital (SD) peripheral: diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h index e2b49fb931..c1730c39a6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sd.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sd.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of SD HAL module. ****************************************************************************** * @attention @@ -610,8 +610,8 @@ typedef enum /* Initialization/de-initialization functions **********************************/ HAL_SD_ErrorTypedef HAL_SD_Init(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypedef *SDCardInfo); HAL_StatusTypeDef HAL_SD_DeInit (SD_HandleTypeDef *hsd); -__weak void HAL_SD_MspInit(SD_HandleTypeDef *hsd); -__weak void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd); +void HAL_SD_MspInit(SD_HandleTypeDef *hsd); +void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd); /* I/O operation functions *****************************************************/ /* Blocking mode: Polling */ @@ -623,12 +623,12 @@ HAL_SD_ErrorTypedef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint64_t startaddr, uint void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd); /* Callback in non blocking modes (DMA) */ -__weak void HAL_SD_DMA_RxCpltCallback(DMA_HandleTypeDef *hdma); -__weak void HAL_SD_DMA_RxErrorCallback(DMA_HandleTypeDef *hdma); -__weak void HAL_SD_DMA_TxCpltCallback(DMA_HandleTypeDef *hdma); -__weak void HAL_SD_DMA_TxErrorCallback(DMA_HandleTypeDef *hdma); -__weak void HAL_SD_XferCpltCallback(SD_HandleTypeDef *hsd); -__weak void HAL_SD_XferErrorCallback(SD_HandleTypeDef *hsd); +void HAL_SD_DMA_RxCpltCallback(DMA_HandleTypeDef *hdma); +void HAL_SD_DMA_RxErrorCallback(DMA_HandleTypeDef *hdma); +void HAL_SD_DMA_TxCpltCallback(DMA_HandleTypeDef *hdma); +void HAL_SD_DMA_TxErrorCallback(DMA_HandleTypeDef *hdma); +void HAL_SD_XferCpltCallback(SD_HandleTypeDef *hsd); +void HAL_SD_XferErrorCallback(SD_HandleTypeDef *hsd); /* Non-Blocking mode: DMA */ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pReadBuffer, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.c index f61708e4e8..66b635cfb9 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sdram.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief SDRAM HAL module driver. * This file provides a generic firmware to drive SDRAM memories mounted * as external device. @@ -102,7 +102,6 @@ * @{ */ #ifdef HAL_SDRAM_MODULE_ENABLED - #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) /* Private typedef -----------------------------------------------------------*/ @@ -176,10 +175,16 @@ HAL_StatusTypeDef HAL_SDRAM_DeInit(SDRAM_HandleTypeDef *hsdram) { /* Initialize the low level hardware (MSP) */ HAL_SDRAM_MspDeInit(hsdram); - + /* Configure the SDRAM registers with their reset values */ FMC_SDRAM_DeInit(hsdram->Instance, hsdram->Init.SDBank); - + + /* Reset the SDRAM controller state */ + hsdram->State = HAL_SDRAM_STATE_RESET; + + /* Release Lock */ + __HAL_UNLOCK(hsdram); + return HAL_OK; } @@ -309,11 +314,11 @@ HAL_StatusTypeDef HAL_SDRAM_Read_8b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddr { *pDstBuffer = *(__IO uint8_t *)pSdramAddress; pDstBuffer++; - pSdramAddress++; + pSdramAddress++; } /* Process Unlocked */ - __HAL_UNLOCK(hsdram); + __HAL_UNLOCK(hsdram); return HAL_OK; } @@ -352,7 +357,7 @@ HAL_StatusTypeDef HAL_SDRAM_Write_8b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAdd { *(__IO uint8_t *)pSdramAddress = *pSrcBuffer; pSrcBuffer++; - pSdramAddress++; + pSdramAddress++; } /* Process Unlocked */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.h index 7672c4ef77..afc8f5c6e3 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sdram.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sdram.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of SDRAM HAL module. ****************************************************************************** * @attention @@ -96,13 +96,13 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_SDRAM_Init(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_TimingTypeDef *Timing); HAL_StatusTypeDef HAL_SDRAM_DeInit(SDRAM_HandleTypeDef *hsdram); -__weak void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram); -__weak void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram); +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram); +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram); void HAL_SDRAM_IRQHandler(SDRAM_HandleTypeDef *hsdram); -__weak void HAL_SDRAM_RefreshErrorCallback(SDRAM_HandleTypeDef *hsdram); -__weak void HAL_SDRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma); -__weak void HAL_SDRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma); +void HAL_SDRAM_RefreshErrorCallback(SDRAM_HandleTypeDef *hsdram); +void HAL_SDRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma); +void HAL_SDRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma); /* I/O operation functions *****************************************************/ HAL_StatusTypeDef HAL_SDRAM_Read_8b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint8_t *pDstBuffer, uint32_t BufferSize); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.c index d557ef2938..49ff894d8b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_smartcard.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief SMARTCARD HAL module driver. * This file provides firmware functions to manage the following * functionalities of the SMARTCARD peripheral: @@ -64,7 +64,7 @@ add his own code by customization of function pointer HAL_SMARTCARD_TxCpltCallback (+) Receive an amount of data in non blocking mode using HAL_SMARTCARD_Receive_IT() (+) At reception end of transfer HAL_SMARTCARD_RxCpltCallback is executed and user can - add his own code by customization of function pointer HAL_SMARTCARD_RxCpltCallback + add his own code by customization of function pointer HAL_SMARTCARD_RxCpltCallback (+) In case of transfer Error, HAL_SMARTCARD_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SMARTCARD_ErrorCallback @@ -76,7 +76,7 @@ add his own code by customization of function pointer HAL_SMARTCARD_TxCpltCallback (+) Receive an amount of data in non blocking mode (DMA) using HAL_SMARTCARD_Receive_DMA() (+) At reception end of transfer HAL_SMARTCARD_RxCpltCallback is executed and user can - add his own code by customization of function pointer HAL_SMARTCARD_RxCpltCallback + add his own code by customization of function pointer HAL_SMARTCARD_RxCpltCallback (+) In case of transfer Error, HAL_SMARTCARD_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SMARTCARD_ErrorCallback @@ -140,6 +140,7 @@ #ifdef HAL_SMARTCARD_MODULE_ENABLED /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ +#define SMARTCARD_TIMEOUT_VALUE 22000 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ @@ -291,7 +292,7 @@ HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc) */ HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc) { - /* Check the SMARTCARD handle allocation */ + /* Check the SMARTCARD handle allocation */ if(hsc == NULL) { return HAL_ERROR; @@ -308,6 +309,9 @@ HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc) hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE; hsc->State = HAL_SMARTCARD_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hsc); + return HAL_OK; } @@ -899,7 +903,7 @@ uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc) * @param hdma : DMA handle * @retval None */ -static void SMARTCARD_DMATransmitCplt(DMA_HandleTypeDef *hdma) +static void SMARTCARD_DMATransmitCplt(DMA_HandleTypeDef *hdma) { SMARTCARD_HandleTypeDef* hsc = ( SMARTCARD_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; @@ -908,10 +912,20 @@ static void SMARTCARD_DMATransmitCplt(DMA_HandleTypeDef *hdma) /* Disable the DMA transfer for transmit request by setting the DMAT bit in the USART CR3 register */ hsc->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DMAT); - - hsc->State= HAL_SMARTCARD_STATE_READY; - - HAL_SMARTCARD_TxCpltCallback(hsc); + + /* Wait for SMARTCARD TC Flag */ + if(SMARTCARD_WaitOnFlagUntilTimeout(hsc, SMARTCARD_FLAG_TC, RESET, SMARTCARD_TIMEOUT_VALUE) != HAL_OK) + { + /* Timeout Occured */ + hsc->State = HAL_SMARTCARD_STATE_TIMEOUT; + HAL_SMARTCARD_ErrorCallback(hsc); + } + else + { + /* No Timeout */ + hsc->State= HAL_SMARTCARD_STATE_READY; + HAL_SMARTCARD_TxCpltCallback(hsc); + } } /** diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h index 46e2eb66a3..c7273feb0b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_smartcard.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_smartcard.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of SMARTCARD HAL module. ****************************************************************************** * @attention @@ -410,8 +410,8 @@ typedef struct HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc); HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc); HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc); -__weak void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc); -__weak void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc); +void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc); +void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc); /* IO operation functions *******************************************************/ HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); @@ -420,9 +420,9 @@ HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc); -__weak void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc); -__weak void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc); -__weak void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc); +void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc); +void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc); +void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc); /* Peripheral State functions **************************************************/ HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c index e32f763e04..40370dcf4c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_spi.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief SPI HAL module driver. * * This file provides firmware functions to manage the following @@ -98,7 +98,7 @@ /* Private function prototypes -----------------------------------------------*/ static void SPI_TxCloseIRQHandler(SPI_HandleTypeDef *hspi); static void SPI_TxISR(SPI_HandleTypeDef *hspi); -static void SPI_RxClose_IRQHandler(SPI_HandleTypeDef *hspi); +static void SPI_RxCloseIRQHandler(SPI_HandleTypeDef *hspi); static void SPI_2LinesRxISR(SPI_HandleTypeDef *hspi); static void SPI_RxISR(SPI_HandleTypeDef *hspi); static void SPI_DMATransmitCplt(DMA_HandleTypeDef *hdma); @@ -229,6 +229,9 @@ HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi) hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->State = HAL_SPI_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hspi); + return HAL_OK; } @@ -653,7 +656,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxD /* Don't overwrite in case of HAL_SPI_STATE_BUSY_RX */ if(hspi->State == HAL_SPI_STATE_READY) { - hspi->State = HAL_SPI_STATE_BUSY_TX_RX; + hspi->State = HAL_SPI_STATE_BUSY_TX_RX; } /* Configure communication */ @@ -1047,7 +1050,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *p /* Don't overwrite in case of HAL_SPI_STATE_BUSY_RX */ if(hspi->State == HAL_SPI_STATE_READY) { - hspi->State = HAL_SPI_STATE_BUSY_TX_RX; + hspi->State = HAL_SPI_STATE_BUSY_TX_RX; } /* Configure communication */ @@ -1281,7 +1284,7 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t * /* Don't overwrite in case of HAL_SPI_STATE_BUSY_RX */ if(hspi->State == HAL_SPI_STATE_READY) { - hspi->State = HAL_SPI_STATE_BUSY_TX_RX; + hspi->State = HAL_SPI_STATE_BUSY_TX_RX; } /* Configure communication */ @@ -1305,9 +1308,15 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t * __HAL_SPI_RESET_CRC(hspi); } - /* Set the SPI Rx DMA transfer complete callback because the last generated transfer request is - the reception request (RXNE) */ - hspi->hdmarx->XferCpltCallback = SPI_DMATransmitReceiveCplt; + /* Check if we are in Rx only or in Rx/Tx Mode and configure the DMA transfer complete callback */ + if(hspi->State == HAL_SPI_STATE_BUSY_RX) + { + hspi->hdmarx->XferCpltCallback = SPI_DMAReceiveCplt; + } + else + { + hspi->hdmarx->XferCpltCallback = SPI_DMATransmitReceiveCplt; + } /* Set the DMA error callback */ hspi->hdmarx->XferErrorCallback = SPI_DMAError; @@ -1518,13 +1527,10 @@ HAL_SPI_ErrorTypeDef HAL_SPI_GetError(SPI_HandleTypeDef *hspi) */ static void SPI_TxCloseIRQHandler(SPI_HandleTypeDef *hspi) { - if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLED) + /* Wait until TXE flag is set to send data */ + if(SPI_WaitOnFlagUntilTimeout(hspi, SPI_FLAG_TXE, RESET, SPI_TIMEOUT_VALUE) != HAL_OK) { - /* Wait until TXE flag is set to send data */ - if(SPI_WaitOnFlagUntilTimeout(hspi, SPI_FLAG_TXE, RESET, SPI_TIMEOUT_VALUE) != HAL_OK) - { - hspi->ErrorCode |= HAL_SPI_ERROR_FLAG; - } + hspi->ErrorCode |= HAL_SPI_ERROR_FLAG; } /* Disable TXE interrupt */ @@ -1547,24 +1553,27 @@ static void SPI_TxCloseIRQHandler(SPI_HandleTypeDef *hspi) __HAL_SPI_CLEAR_OVRFLAG(hspi); } - /* Set state to READY before run the Callback Complete */ - hspi->State = HAL_SPI_STATE_READY; - /* Check if Errors has been detected during transfer */ if(hspi->ErrorCode == HAL_SPI_ERROR_NONE) { /* Check if we are in Tx or in Rx/Tx Mode */ if(hspi->State == HAL_SPI_STATE_BUSY_TX_RX) { + /* Set state to READY before run the Callback Complete */ + hspi->State = HAL_SPI_STATE_READY; HAL_SPI_TxRxCpltCallback(hspi); } else { - HAL_SPI_TxRxCpltCallback(hspi); + /* Set state to READY before run the Callback Complete */ + hspi->State = HAL_SPI_STATE_READY; + HAL_SPI_TxCpltCallback(hspi); } } else { + /* Set state to READY before run the Callback Complete */ + hspi->State = HAL_SPI_STATE_READY; /* Call Error call back in case of Error */ HAL_SPI_ErrorCallback(hspi); } @@ -1607,7 +1616,7 @@ static void SPI_TxISR(SPI_HandleTypeDef *hspi) * @param hspi: SPI handle * @retval void */ -static void SPI_RxClose_IRQHandler(SPI_HandleTypeDef *hspi) +static void SPI_RxCloseIRQHandler(SPI_HandleTypeDef *hspi) { __IO uint16_t tmpreg; @@ -1653,22 +1662,26 @@ static void SPI_RxClose_IRQHandler(SPI_HandleTypeDef *hspi) __HAL_SPI_DISABLE(hspi); } - /* Set state to READY before run the Callback Complete */ - hspi->State = HAL_SPI_STATE_READY; /* Check if Errors has been detected during transfer */ if(hspi->ErrorCode == HAL_SPI_ERROR_NONE) { /* Check if we are in Rx or in Rx/Tx Mode */ if(hspi->State == HAL_SPI_STATE_BUSY_TX_RX) { + /* Set state to READY before run the Callback Complete */ + hspi->State = HAL_SPI_STATE_READY; HAL_SPI_TxRxCpltCallback(hspi); }else { + /* Set state to READY before run the Callback Complete */ + hspi->State = HAL_SPI_STATE_READY; HAL_SPI_RxCpltCallback(hspi); } } else { + /* Set state to READY before run the Callback Complete */ + hspi->State = HAL_SPI_STATE_READY; /* Call Error call back in case of Error */ HAL_SPI_ErrorCallback(hspi); } @@ -1697,7 +1710,7 @@ static void SPI_2LinesRxISR(SPI_HandleTypeDef *hspi) if(hspi->RxXferCount==0) { - SPI_RxClose_IRQHandler(hspi); + SPI_RxCloseIRQHandler(hspi); } } @@ -1730,7 +1743,7 @@ static void SPI_RxISR(SPI_HandleTypeDef *hspi) if(hspi->RxXferCount == 0) { - SPI_RxClose_IRQHandler(hspi); + SPI_RxCloseIRQHandler(hspi); } } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h index 190d489b40..c8929d36d8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_spi.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_spi.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of SPI HAL module. ****************************************************************************** * @attention @@ -448,10 +448,10 @@ HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi); -__weak void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi); -__weak void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi); -__weak void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi); -__weak void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi); +void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi); +void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi); +void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi); +void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi); /* Peripheral State and Control functions **************************************/ HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c index 2ff4f701c0..9aef8953de 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sram.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief SRAM HAL module driver. * This file provides a generic firmware to drive SRAM memories * mounted as external device. @@ -180,7 +180,12 @@ HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram) /* Configure the SRAM registers with their reset values */ FMC_NORSRAM_DeInit(hsram->Instance, hsram->Extended, hsram->Init.NSBank); - + + hsram->State = HAL_SRAM_STATE_RESET; + + /* Release Lock */ + __HAL_UNLOCK(hsram); + return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h index 9dacbcf3e2..0cb6a33a68 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_sram.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_sram.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of SRAM HAL module. ****************************************************************************** * @attention @@ -104,8 +104,8 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_SRAM_Init(SRAM_HandleTypeDef *hsram, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming); HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram); -__weak void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram); -__weak void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram); +void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram); +void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram); /* I/O operation functions *****************************************************/ HAL_StatusTypeDef HAL_SRAM_Read_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pDstBuffer, uint32_t BufferSize); @@ -117,8 +117,8 @@ HAL_StatusTypeDef HAL_SRAM_Write_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddre HAL_StatusTypeDef HAL_SRAM_Read_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize); HAL_StatusTypeDef HAL_SRAM_Write_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize); -__weak void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma); -__weak void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma); +void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma); +void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma); /* SRAM Control functions ******************************************************/ HAL_StatusTypeDef HAL_SRAM_WriteOperation_Enable(SRAM_HandleTypeDef *hsram); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c index 53f635b17b..4691f46a45 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_tim.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief TIM HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Timer (TIM) peripheral: @@ -248,6 +248,9 @@ HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim) /* Change TIM state */ htim->State = HAL_TIM_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(htim); + return HAL_OK; } @@ -511,7 +514,10 @@ HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim) /* Change TIM state */ htim->State = HAL_TIM_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(htim); + return HAL_OK; } @@ -1005,7 +1011,10 @@ HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim) /* Change TIM state */ htim->State = HAL_TIM_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(htim); + return HAL_OK; } @@ -1502,7 +1511,10 @@ HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim) /* Change TIM state */ htim->State = HAL_TIM_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(htim); + return HAL_OK; } @@ -1971,8 +1983,11 @@ HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim) HAL_TIM_OnePulse_MspDeInit(htim); /* Change TIM state */ - htim->State = HAL_TIM_STATE_RESET; - + htim->State = HAL_TIM_STATE_RESET; + + /* Release Lock */ + __HAL_UNLOCK(htim); + return HAL_OK; } @@ -2274,8 +2289,11 @@ HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim) HAL_TIM_Encoder_MspDeInit(htim); /* Change TIM state */ - htim->State = HAL_TIM_STATE_RESET; - + htim->State = HAL_TIM_STATE_RESET; + + /* Release Lock */ + __HAL_UNLOCK(htim); + return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h index 7f65c97caa..c324399105 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_tim.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of TIM HAL module. ****************************************************************************** * @attention @@ -1414,12 +1414,12 @@ HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventS uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel); /* Callback in non blocking modes (Interrupt and DMA) *************************/ -__weak void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim); -__weak void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim); -__weak void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim); -__weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim); -__weak void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim); -__weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim); +void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim); +void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim); +void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim); +void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim); +void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim); +void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim); /* Peripheral State functions **************************************************/ HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.c index 8f0b0729f0..a4d7d2b9fc 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_tim_ex.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief TIM HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Timer extension peripheral: @@ -236,7 +236,10 @@ HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim) /* Change TIM state */ htim->State = HAL_TIM_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(htim); + return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.h index 9074db2e49..5e3bc61460 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_tim_ex.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_tim_ex.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of TIM HAL Extension module. ****************************************************************************** * @attention @@ -209,8 +209,8 @@ HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef* htim, TIM_Bre HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef* htim, uint32_t Remap); /* Extension Callback *********************************************************/ -__weak void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef* htim); -__weak void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef* htim); +void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef* htim); +void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef* htim); void HAL_TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma); /* Extension Peripheral State functions **************************************/ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c index 9281edacd8..9c6f49eb2c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_uart.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief UART HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Universal Asynchronous Receiver Transmitter (UART) peripheral: @@ -168,6 +168,7 @@ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ +#define UART_TIMEOUT_VALUE 22000 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ @@ -466,7 +467,10 @@ HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart) huart->ErrorCode = HAL_UART_ERROR_NONE; huart->State = HAL_UART_STATE_RESET; - + + /* Process Lock */ + __HAL_UNLOCK(huart); + return HAL_OK; } @@ -1008,6 +1012,12 @@ HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart) /* Disable the UART DMA Rx request */ huart->Instance->CR3 &= (uint32_t)(~USART_CR3_DMAR); } + else if (huart->State == HAL_UART_STATE_BUSY_TX_RX) + { + /* Disable the UART DMA Tx & Rx requests */ + huart->Instance->CR3 &= (uint32_t)(~USART_CR3_DMAT); + huart->Instance->CR3 &= (uint32_t)(~USART_CR3_DMAR); + } /* Process Unlocked */ __HAL_UNLOCK(huart); @@ -1035,6 +1045,12 @@ HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart) /* Enable the UART DMA Rx request */ huart->Instance->CR3 |= USART_CR3_DMAR; } + else if(huart->State == HAL_UART_STATE_BUSY_TX_RX) + { + /* Enable the UART DMA Tx & Rx request */ + huart->Instance->CR3 |= USART_CR3_DMAT; + huart->Instance->CR3 |= USART_CR3_DMAR; + } /* If the UART peripheral is still not enabled, enable it */ if ((huart->Instance->CR1 & USART_CR1_UE) == 0) @@ -1063,10 +1079,16 @@ HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart) huart->Instance->CR3 &= ~USART_CR3_DMAT; huart->Instance->CR3 &= ~USART_CR3_DMAR; - /* Disable the UART DMA Stream */ - __HAL_DMA_DISABLE(huart->hdmatx); - __HAL_DMA_DISABLE(huart->hdmarx); - + /* Abort the UART DMA tx Stream */ + if(huart->hdmatx != NULL) + { + HAL_DMA_Abort(huart->hdmatx); + } + /* Abort the UART DMA rx Stream */ + if(huart->hdmarx != NULL) + { + HAL_DMA_Abort(huart->hdmarx); + } /* Disable UART peripheral */ __HAL_UART_DISABLE(huart); @@ -1442,17 +1464,28 @@ static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma) /* Disable the DMA transfer for transmit request by setting the DMAT bit in the UART CR3 register */ huart->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DMAT); - - /* Check if a receive process is ongoing or not */ - if(huart->State == HAL_UART_STATE_BUSY_TX_RX) + + /* Wait for UART TC Flag */ + if(UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TC, RESET, UART_TIMEOUT_VALUE) != HAL_OK) { - huart->State = HAL_UART_STATE_BUSY_RX; + /* Timeout Occured */ + huart->State = HAL_UART_STATE_TIMEOUT; + HAL_UART_ErrorCallback(huart); } else { - huart->State = HAL_UART_STATE_READY; + /* No Timeout */ + /* Check if a receive process is ongoing or not */ + if(huart->State == HAL_UART_STATE_BUSY_TX_RX) + { + huart->State = HAL_UART_STATE_BUSY_RX; + } + else + { + huart->State = HAL_UART_STATE_READY; + } + HAL_UART_TxCpltCallback(huart); } - HAL_UART_TxCpltCallback(huart); } /** diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h index 3daff65f22..194f4571a8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_uart.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_uart.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of UART HAL module. ****************************************************************************** * @attention @@ -432,8 +432,8 @@ HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart); HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength); HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethode); HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart); -__weak void HAL_UART_MspInit(UART_HandleTypeDef *huart); -__weak void HAL_UART_MspDeInit(UART_HandleTypeDef *huart); +void HAL_UART_MspInit(UART_HandleTypeDef *huart); +void HAL_UART_MspDeInit(UART_HandleTypeDef *huart); /* IO operation functions *******************************************************/ HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout); @@ -446,11 +446,11 @@ HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart); HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart); HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart); void HAL_UART_IRQHandler(UART_HandleTypeDef *huart); -__weak void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart); -__weak void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart); -__weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart); -__weak void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart); -__weak void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart); +void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart); +void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart); +void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart); +void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart); +void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart); /* Peripheral Control functions ************************************************/ HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.c index a1d8834149..f0b7dbd0ff 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_usart.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief USART HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Universal Synchronous Asynchronous Receiver Transmitter (USART) peripheral: @@ -151,6 +151,7 @@ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define DYMMY_DATA 0xFFFF +#define USART_TIMEOUT_VALUE 22000 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ @@ -280,7 +281,10 @@ HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart) husart->ErrorCode = HAL_USART_ERROR_NONE; husart->State = HAL_USART_STATE_RESET; - + + /* Release Lock */ + __HAL_UNLOCK(husart); + return HAL_OK; } @@ -1084,10 +1088,16 @@ HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart) husart->Instance->CR3 &= ~USART_CR3_DMAT; husart->Instance->CR3 &= ~USART_CR3_DMAR; - /* Disable the USART DMA Stream */ - __HAL_DMA_DISABLE(husart->hdmatx); - __HAL_DMA_DISABLE(husart->hdmarx); - + /* Abort the USART DMA Tx Stream */ + if(husart->hdmatx != NULL) + { + HAL_DMA_Abort(husart->hdmatx); + } + /* Abort the USART DMA Rx Stream */ + if(husart->hdmarx != NULL) + { + HAL_DMA_Abort(husart->hdmarx); + } /* Disable USART peripheral */ __USART_DISABLE(husart); @@ -1316,18 +1326,28 @@ static void USART_DMATransmitCplt(DMA_HandleTypeDef *hdma) husart->TxXferCount = 0; if(husart->State == HAL_USART_STATE_BUSY_TX) { - /* Disable the DMA transfer for transmit request by setting the DMAT bit - in the USART CR3 register */ - husart->Instance->CR3 &= ~(USART_CR3_DMAT); - husart->State= HAL_USART_STATE_READY; + /* Wait for USART TC Flag */ + if(USART_WaitOnFlagUntilTimeout(husart, USART_FLAG_TC, RESET, USART_TIMEOUT_VALUE) != HAL_OK) + { + /* Timeout Occured */ + husart->State = HAL_USART_STATE_TIMEOUT; + HAL_USART_ErrorCallback(husart); + } + else + { + /* No Timeout */ + /* Disable the DMA transfer for transmit request by setting the DMAT bit + in the USART CR3 register */ + husart->Instance->CR3 &= ~(USART_CR3_DMAT); + husart->State= HAL_USART_STATE_READY; + } } /* the usart state is HAL_USART_STATE_BUSY_TX_RX*/ else { husart->State= HAL_USART_STATE_BUSY_RX; + HAL_USART_TxCpltCallback(husart); } - - HAL_USART_TxCpltCallback(husart); } /** diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.h index 501ea2f541..b73c341ff1 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_usart.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_usart.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of USART HAL module. ****************************************************************************** * @attention @@ -410,8 +410,8 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart); HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart); -__weak void HAL_USART_MspInit(USART_HandleTypeDef *husart); -__weak void HAL_USART_MspDeInit(USART_HandleTypeDef *husart); +void HAL_USART_MspInit(USART_HandleTypeDef *husart); +void HAL_USART_MspDeInit(USART_HandleTypeDef *husart); /* IO operation functions *******************************************************/ HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); @@ -426,12 +426,12 @@ HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart); HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart); HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart); void HAL_USART_IRQHandler(USART_HandleTypeDef *husart); -__weak void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart); -__weak void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart); -__weak void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart); -__weak void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart); -__weak void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart); -__weak void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart); +void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart); +void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart); +void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart); +void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart); +void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart); +void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart); /* Peripheral State functions **************************************************/ HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c index ef97b0d21a..499542aa78 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_wwdg.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief WWDG HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Window Watchdog (WWDG) peripheral: @@ -229,6 +229,9 @@ HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg) /* Change WWDG peripheral state */ hwwdg->State = HAL_WWDG_STATE_RESET; + /* Release Lock */ + __HAL_UNLOCK(hwwdg); + /* Return function status */ return HAL_OK; } diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h index 574c28510f..51500c82f8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_wwdg.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_wwdg.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of WWDG HAL module. ****************************************************************************** * @attention @@ -222,9 +222,9 @@ typedef struct /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg); HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg); -__weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg); -__weak void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg); -__weak void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg); +void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg); +void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg); +void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg); /* I/O operation functions ******************************************************/ HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg); diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c index c9ee5cceb7..536659e4ff 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_fmc.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief FMC Low Layer HAL module driver. * * This file provides firmware functions to manage the following @@ -15,7 +15,7 @@ @verbatim ============================================================================== ##### FMC peripheral features ##### - ============================================================================== + ============================================================================== [..] The Flexible memory controller (FMC) includes three memory controllers: (+) The NOR/PSRAM memory controller (+) The NAND/PC Card memory controller @@ -91,7 +91,7 @@ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ @@ -170,7 +170,7 @@ HAL_StatusTypeDef FMC_NORSRAM_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_Ini assert_param(IS_FMC_WRITE_BURST(Init->WriteBurst)); assert_param(IS_FMC_CONTINOUS_CLOCK(Init->ContinuousClock)); - /* Set NORSRAM device control parameters */ + /* Set NORSRAM device control parameters */ tmpr = (uint32_t)(Init->DataAddressMux |\ Init->MemoryType |\ Init->MemoryDataWidth |\ @@ -399,7 +399,7 @@ HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Disable(FMC_NORSRAM_TypeDef *Device * @brief PCCARD Controller functions * @verbatim - ============================================================================== + ============================================================================== ##### How to use NAND device driver ##### ============================================================================== [..] @@ -1035,9 +1035,9 @@ HAL_StatusTypeDef FMC_SDRAM_Timing_Init(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_Tim (((Timing->WriteRecoveryTime)-1) <<16) |\ (((Timing->RPDelay)-1) << 20) |\ (((Timing->RCDDelay)-1) << 24) - ); + ); } - else /* FMC_Bank2_SDRAM */ + else /* FMC_Bank2_SDRAM */ { tmpr1 = (uint32_t)(((Timing->LoadToActiveDelay)-1) |\ @@ -1161,7 +1161,7 @@ HAL_StatusTypeDef FMC_SDRAM_SendCommand(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_Com ((Command->ModeRegisterDefinition) << 9) ); - Device->SDCMR = tmpr; + Device->SDCMR = tmpr; timeout = HAL_GetTick() + Timeout; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h index a5668abd33..2e651798cd 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fmc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_fmc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of FMC HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c index 18f3fcfa56..21d5b75b07 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_fsmc.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief FSMC Low Layer HAL module driver. * * This file provides firmware functions to manage the following @@ -165,7 +165,7 @@ HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_ assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait)); assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst)); - /* Set NORSRAM device control parameters */ + /* Set NORSRAM device control parameters */ tmpr = (uint32_t)(Init->DataAddressMux |\ Init->MemoryType |\ Init->MemoryDataWidth |\ @@ -312,7 +312,7 @@ HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeD @verbatim ============================================================================== ##### FSMC_NORSRAM Control functions ##### - ============================================================================== + ============================================================================== [..] This subsection provides a set of functions allowing to control dynamically the FSMC NORSRAM interface. diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h index c6c7d7a7c4..62ff87be57 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_fsmc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_fsmc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of FSMC HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c index 7462b1c878..f06ceb8062 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_sdmmc.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief SDMMC Low Layer HAL module driver. * * This file provides firmware functions to manage the following diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h index 9914bab589..8eaaecfe8b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_sdmmc.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_sdmmc.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of SDMMC HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c index 49c44921b9..cbad9541e9 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_usb.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief USB Low Layer HAL module driver. * * This file provides firmware functions to manage the following @@ -112,10 +112,6 @@ HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c { USBx->GUSBCFG |= USB_OTG_GUSBCFG_ULPIEVBUSD; } - else - { - USBx->GUSBCFG |= USB_OTG_GUSBCFG_ULPIEVBUSI; - } /* Reset after a PHY select */ USB_CoreReset(USBx); } @@ -124,26 +120,14 @@ HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c /* Select FS Embedded PHY */ USBx->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL; - + /* Reset after a PHY select and set Host mode */ USB_CoreReset(USBx); /* Deactivate the power down*/ USBx->GCCFG = USB_OTG_GCCFG_PWRDWN; - - /*Activate VBUS Sensing A & B */ - USBx->GCCFG |= (USB_OTG_GCCFG_VBUSASEN | USB_OTG_GCCFG_VBUSBSEN); - - if (cfg.vbus_sensing_enable == ENABLE) - { - USBx->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; - } } - if (cfg.Sof_enable == ENABLE) - { - USBx->GCCFG |= USB_OTG_GCCFG_SOFOUTEN; - } - + if(cfg.dma_enable == ENABLE) { USBx->GAHBCFG |= (USB_OTG_GAHBCFG_HBSTLEN_1 | USB_OTG_GAHBCFG_HBSTLEN_2); @@ -216,6 +200,15 @@ HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx , USB_OTG_ModeT HAL_StatusTypeDef USB_DevInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg) { uint32_t i = 0; + + /*Activate VBUS Sensing B */ + USBx->GCCFG |= USB_OTG_GCCFG_VBUSBSEN; + + if (cfg.vbus_sensing_enable == 0) + { + USBx->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + } + /* Restart the Phy Clock */ USBx_PCGCCTL = 0; @@ -308,9 +301,14 @@ HAL_StatusTypeDef USB_DevInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef c /* Enable interrupts matching to the Device mode ONLY */ USBx->GINTMSK |= (USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_USBRST |\ USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_IEPINT |\ - USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_SOFM |\ - USB_OTG_GINTMSK_IISOIXFRM| USB_OTG_GINTMSK_PXFRM_IISOOXFRM); + USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_IISOIXFRM|\ + USB_OTG_GINTMSK_PXFRM_IISOOXFRM | USB_OTG_GINTMSK_WUIM); + if(cfg.Sof_enable) + { + USBx->GINTMSK |= USB_OTG_GINTMSK_SOFM; + } + if (cfg.vbus_sensing_enable == ENABLE) { USBx->GINTMSK |= (USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_OTGINT); @@ -338,10 +336,11 @@ HAL_StatusTypeDef USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num ) { if (++count > 200000) { - break; + return HAL_TIMEOUT; } } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH); + return HAL_OK; } @@ -361,10 +360,11 @@ HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx) { if (++count > 200000) { - break; + return HAL_TIMEOUT; } } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_RXFFLSH) == USB_OTG_GRSTCTL_RXFFLSH); + return HAL_OK; } @@ -426,22 +426,24 @@ HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTy { if (ep->is_in == 1) { + USBx_DEVICE->DAINTMSK |= USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num))); + if (((USBx_INEP(ep->num)->DIEPCTL) & USB_OTG_DIEPCTL_USBAEP) == 0) { USBx_INEP(ep->num)->DIEPCTL |= ((ep->maxpacket & USB_OTG_DIEPCTL_MPSIZ ) | (ep->type << 18 ) |\ - ((ep->num + 1) << 22 ) | (USB_OTG_DIEPCTL_SD0PID_SEVNFRM) | (USB_OTG_DIEPCTL_USBAEP)); + ((ep->num) << 22 ) | (USB_OTG_DIEPCTL_SD0PID_SEVNFRM) | (USB_OTG_DIEPCTL_USBAEP)); } - USBx_DEVICE->DAINTMSK |= USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num))); + } else { + USBx_DEVICE->DAINTMSK |= USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16); + if (((USBx_OUTEP(ep->num)->DOEPCTL) & USB_OTG_DOEPCTL_USBAEP) == 0) { USBx_OUTEP(ep->num)->DOEPCTL |= ((ep->maxpacket & USB_OTG_DOEPCTL_MPSIZ ) | (ep->type << 18 ) |\ - ((ep->num + 1) << 22 ) | (USB_OTG_DOEPCTL_USBAEP)); + (USB_OTG_DIEPCTL_SD0PID_SEVNFRM)| (USB_OTG_DOEPCTL_USBAEP)); } - - USBx_DEVICE->DAINTMSK |= USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16); } return HAL_OK; } @@ -499,13 +501,16 @@ HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EP /* Read DEPCTLn register */ if (ep->is_in == 1) { - USBx_INEP(ep->num)->DIEPCTL &= ~ USB_OTG_DIEPCTL_USBAEP; USBx_DEVICE->DEACHMSK &= ~(USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num)))); + USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_IEPM & ((1 << (ep->num)))); + USBx_INEP(ep->num)->DIEPCTL &= ~ USB_OTG_DIEPCTL_USBAEP; } else { - USBx_OUTEP(ep->num)->DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP; + USBx_DEVICE->DEACHMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16)); + USBx_DEVICE->DAINTMSK &= ~(USB_OTG_DAINTMSK_OEPM & ((1 << (ep->num)) << 16)); + USBx_OUTEP(ep->num)->DOEPCTL &= ~USB_OTG_DOEPCTL_USBAEP; } return HAL_OK; } @@ -1077,10 +1082,9 @@ static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx) /* Wait for AHB master IDLE state. */ do { - HAL_Delay(1); if (++count > 200000) { - return HAL_OK;; + return HAL_TIMEOUT; } } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0); @@ -1093,14 +1097,11 @@ static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx) { if (++count > 200000) { - break; + return HAL_TIMEOUT; } } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST); - /* Wait for at least 3 PHY Clocks*/ - HAL_Delay(1); - return HAL_OK; } @@ -1120,9 +1121,13 @@ HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef /* Restart the Phy Clock */ USBx_PCGCCTL = 0; + /* no VBUS sensing*/ + USBx->GCCFG &=~ (USB_OTG_GCCFG_VBUSASEN); + USBx->GCCFG &=~ (USB_OTG_GCCFG_VBUSBSEN); + USBx->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; + /* Disable the FS/LS support mode only */ - if(((cfg.speed == USB_OTG_SPEED_FULL) || - (cfg.speed == USB_OTG_SPEED_LOW))&& + if((cfg.speed == USB_OTG_SPEED_FULL)&& (USBx != USB_OTG_FS)) { USBx_HOST->HCFG |= USB_OTG_HCFG_FSLSS; @@ -1160,7 +1165,7 @@ HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef /* set Rx FIFO size */ USBx->GRXFSIZ = (uint32_t )0x80; USBx->DIEPTXF0_HNPTXFSIZ = (uint32_t )(((0x60 << 16)& USB_OTG_NPTXFD) | 0x80); - USBx->HPTXFSIZ = (uint32_t )(((0x60 << 16)& USB_OTG_HPTXFSIZ_PTXFD) | 0xE0); + USBx->HPTXFSIZ = (uint32_t )(((0x40 << 16)& USB_OTG_HPTXFSIZ_PTXFD) | 0xE0); } @@ -1169,7 +1174,7 @@ HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef /* set Rx FIFO size */ USBx->GRXFSIZ = (uint32_t )0x200; USBx->DIEPTXF0_HNPTXFSIZ = (uint32_t )(((0x100 << 16)& USB_OTG_NPTXFD) | 0x200); - USBx->HPTXFSIZ = (uint32_t )(((0x100 << 16)& USB_OTG_HPTXFSIZ_PTXFD) | 0x300); + USBx->HPTXFSIZ = (uint32_t )(((0xE0 << 16)& USB_OTG_HPTXFSIZ_PTXFD) | 0x300); } /* Enable the common interrupts */ @@ -1180,12 +1185,9 @@ HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef /* Enable interrupts matching to the Host mode ONLY */ USBx->GINTMSK |= (USB_OTG_GINTMSK_PRTIM | USB_OTG_GINTMSK_HCIM |\ - USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_SOFM |\ - USB_OTG_GINTMSK_PXFRM_IISOOXFRM | USB_OTG_GINTMSK_WUIM | - USB_OTG_GINTSTS_DISCINT); + USB_OTG_GINTMSK_SOFM |USB_OTG_GINTSTS_DISCINT|\ + USB_OTG_GINTMSK_PXFRM_IISOOXFRM | USB_OTG_GINTMSK_WUIM); - - return HAL_OK; } @@ -1233,7 +1235,7 @@ HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx) USBx_HPRT0 = (USB_OTG_HPRT_PRST | hprt0); HAL_Delay (10); /* See Note #1 */ - USBx_HPRT0 = ((~USB_OTG_HPRT_PRST) & hprt0); + USBx_HPRT0 = ((~USB_OTG_HPRT_PRST) & hprt0); return HAL_OK; } @@ -1396,7 +1398,7 @@ HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, ((ep_type << 18) & USB_OTG_HCCHAR_EPTYP)|\ (mps & USB_OTG_HCCHAR_MPSIZ)); - if (ep_type == HCCHAR_INTR) + if (ep_type == EP_TYPE_INTR) { USBx_HC(ch_num)->HCCHAR |= USB_OTG_HCCHAR_ODDFRM ; } @@ -1540,7 +1542,8 @@ uint32_t USB_HC_ReadInterrupt (USB_OTG_GlobalTypeDef *USBx) */ HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx , uint8_t hc_num) { - + uint32_t count = 0; + /* Check for space in the request queue to issue the halt. */ if (((USBx_HC(hc_num)->HCCHAR) & (HCCHAR_CTRL << 18)) || ((USBx_HC(hc_num)->HCCHAR) & (HCCHAR_BULK << 18))) { @@ -1548,11 +1551,21 @@ HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx , uint8_t hc_num) if ((USBx->HNPTXSTS & 0xFFFF) == 0) { - USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_CHENA; + USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_CHENA; + USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA; + USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_EPDIR; + do + { + if (++count > 1000) + { + break; + } + } + while ((USBx_HC(hc_num)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA); } else { - USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA; + USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA; } } else @@ -1561,7 +1574,17 @@ HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx , uint8_t hc_num) if ((USBx_HOST->HPTXSTS & 0xFFFF) == 0) { - USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_CHENA; + USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_CHENA; + USBx_HC(hc_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA; + USBx_HC(hc_num)->HCCHAR &= ~USB_OTG_HCCHAR_EPDIR; + do + { + if (++count > 1000) + { + break; + } + } + while ((USBx_HC(hc_num)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA); } else { @@ -1601,18 +1624,47 @@ HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx , uint8_t ch_num) HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx) { uint8_t i; + uint32_t count = 0; + uint32_t value; + USB_DisableGlobalInt(USBx); - /* Halt all the Host Channels */ - for (i = 0; i <= 15; i++) - { - USB_HC_Halt(USBx , i); - } - - /* Flush FIFO */ + /* Flush FIFO */ USB_FlushTxFifo(USBx, 0x10); USB_FlushRxFifo(USBx); + /* Flush out any leftover queued requests. */ + for (i = 0; i <= 15; i++) + { + + value = USBx_HC(i)->HCCHAR ; + value |= USB_OTG_HCCHAR_CHDIS; + value &= ~USB_OTG_HCCHAR_CHENA; + value &= ~USB_OTG_HCCHAR_EPDIR; + USBx_HC(i)->HCCHAR = value; + } + + /* Halt all channels to put them into a known state. */ + for (i = 0; i <= 15; i++) + { + + value = USBx_HC(i)->HCCHAR ; + + value |= USB_OTG_HCCHAR_CHDIS; + value |= USB_OTG_HCCHAR_CHENA; + value &= ~USB_OTG_HCCHAR_EPDIR; + + USBx_HC(i)->HCCHAR = value; + do + { + if (++count > 1000) + { + break; + } + } + while ((USBx_HC(i)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA); + } + /* Clear any pending Host interrups */ USBx_HOST->HAINT = 0xFFFFFFFF; USBx->GINTSTS = 0xFFFFFFFF; diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h index 5d7ba55181..97c41de1e5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_ll_usb.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_ll_usb.h * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief Header file of USB Core HAL module. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c index f9c57b2c0c..ebea6d46c7 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file system_stm32f4xx.c * @author MCD Application Team - * @version V0.8.0 - * @date 03-January-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. * * This file provides two functions and one global variable to be called from @@ -26,17 +26,27 @@ * *

© COPYRIGHT 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ @@ -72,13 +82,6 @@ */ /************************* Miscellaneous Configuration ************************/ -/*!< Uncomment the following line if you need to use external SRAM or SDRAM mounted - on STM324xG_EVAL/STM324x9I_EVAL boards as data memory */ -/* #define DATA_IN_ExtSRAM */ -/* #define DATA_IN_ExtSDRAM */ -#if defined(DATA_IN_ExtSRAM) && defined(DATA_IN_ExtSDRAM) - #error "Please select DATA_IN_ExtSRAM or DATA_IN_ExtSDRAM " -#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ @@ -121,10 +124,6 @@ * @{ */ -#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) - static void SystemInit_ExtMemCtl(void); -#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ - /** * @} */ @@ -165,10 +164,6 @@ void SystemInit(void) /* Disable all interrupts */ RCC->CIR = 0x00000000; -#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) - SystemInit_ExtMemCtl(); -#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ - /* Configure the Vector Table location add offset address ------------------*/ #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ @@ -214,14 +209,14 @@ void SysTick_Handler(void) * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied/divided by the PLL factors. * - * (*) HSI_VALUE is a constant defined in stm32f4xx_hal.h file (default value + * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value * 16 MHz) but the real value may vary depending on the variations * in voltage and temperature. * - * (**) HSE_VALUE is a constant defined in stm32f4xx_hal.h file (default value - * 25 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. + * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value + * depends on the application requirements), user has to ensure that HSE_VALUE + * is same as the real frequency of the crystal used. Otherwise, this function + * may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. @@ -277,237 +272,6 @@ void SystemCoreClockUpdate(void) SystemCoreClock >>= tmp; } -#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) -/** - * @brief Setup the external memory controller. - * Called in startup_stm32f4xx.s before jump to main. - * This function configures the external memories (SRAM/SDRAM) - * This SRAM/SDRAM will be used as program data memory (including heap and stack). - * @param None - * @retval None - */ -void SystemInit_ExtMemCtl(void) -{ -#if defined (DATA_IN_ExtSDRAM) - register uint32_t tmpreg = 0, timeout = 0xFFFF; - register uint32_t index; - - /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface - clock */ - RCC->AHB1ENR |= 0x000001FC; - - /* Connect PCx pins to FMC Alternate function */ - GPIOC->AFR[0] = 0x0000000c; - GPIOC->AFR[1] = 0x00007700; - /* Configure PCx pins in Alternate function mode */ - GPIOC->MODER = 0x00a00002; - /* Configure PCx pins speed to 50 MHz */ - GPIOC->OSPEEDR = 0x00a00002; - /* Configure PCx pins Output type to push-pull */ - GPIOC->OTYPER = 0x00000000; - /* No pull-up, pull-down for PCx pins */ - GPIOC->PUPDR = 0x00500000; - - /* Connect PDx pins to FMC Alternate function */ - GPIOD->AFR[0] = 0x000000CC; - GPIOD->AFR[1] = 0xCC000CCC; - /* Configure PDx pins in Alternate function mode */ - GPIOD->MODER = 0xA02A000A; - /* Configure PDx pins speed to 50 MHz */ - GPIOD->OSPEEDR = 0xA02A000A; - /* Configure PDx pins Output type to push-pull */ - GPIOD->OTYPER = 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOD->PUPDR = 0x00000000; - - /* Connect PEx pins to FMC Alternate function */ - GPIOE->AFR[0] = 0xC00000CC; - GPIOE->AFR[1] = 0xCCCCCCCC; - /* Configure PEx pins in Alternate function mode */ - GPIOE->MODER = 0xAAAA800A; - /* Configure PEx pins speed to 50 MHz */ - GPIOE->OSPEEDR = 0xAAAA800A; - /* Configure PEx pins Output type to push-pull */ - GPIOE->OTYPER = 0x00000000; - /* No pull-up, pull-down for PEx pins */ - GPIOE->PUPDR = 0x00000000; - - /* Connect PFx pins to FMC Alternate function */ - GPIOF->AFR[0] = 0xcccccccc; - GPIOF->AFR[1] = 0xcccccccc; - /* Configure PFx pins in Alternate function mode */ - GPIOF->MODER = 0xAA800AAA; - /* Configure PFx pins speed to 50 MHz */ - GPIOF->OSPEEDR = 0xAA800AAA; - /* Configure PFx pins Output type to push-pull */ - GPIOF->OTYPER = 0x00000000; - /* No pull-up, pull-down for PFx pins */ - GPIOF->PUPDR = 0x00000000; - - /* Connect PGx pins to FMC Alternate function */ - GPIOG->AFR[0] = 0xcccccccc; - GPIOG->AFR[1] = 0xcccccccc; - /* Configure PGx pins in Alternate function mode */ - GPIOG->MODER = 0xaaaaaaaa; - /* Configure PGx pins speed to 50 MHz */ - GPIOG->OSPEEDR = 0xaaaaaaaa; - /* Configure PGx pins Output type to push-pull */ - GPIOG->OTYPER = 0x00000000; - /* No pull-up, pull-down for PGx pins */ - GPIOG->PUPDR = 0x00000000; - - /* Connect PHx pins to FMC Alternate function */ - GPIOH->AFR[0] = 0x00C0CC00; - GPIOH->AFR[1] = 0xCCCCCCCC; - /* Configure PHx pins in Alternate function mode */ - GPIOH->MODER = 0xAAAA08A0; - /* Configure PHx pins speed to 50 MHz */ - GPIOH->OSPEEDR = 0xAAAA08A0; - /* Configure PHx pins Output type to push-pull */ - GPIOH->OTYPER = 0x00000000; - /* No pull-up, pull-down for PHx pins */ - GPIOH->PUPDR = 0x00000000; - - /* Connect PIx pins to FMC Alternate function */ - GPIOI->AFR[0] = 0xCCCCCCCC; - GPIOI->AFR[1] = 0x00000CC0; - /* Configure PIx pins in Alternate function mode */ - GPIOI->MODER = 0x0028AAAA; - /* Configure PIx pins speed to 50 MHz */ - GPIOI->OSPEEDR = 0x0028AAAA; - /* Configure PIx pins Output type to push-pull */ - GPIOI->OTYPER = 0x00000000; - /* No pull-up, pull-down for PIx pins */ - GPIOI->PUPDR = 0x00000000; - -/*-- FMC Configuration ------------------------------------------------------*/ - /* Enable the FMC interface clock */ - RCC->AHB3ENR |= 0x00000001; - - /* Configure and enable SDRAM bank1 */ - FMC_Bank5_6->SDCR[0] = 0x000029D0; - FMC_Bank5_6->SDTR[0] = 0x01115351; - - /* SDRAM initialization sequence */ - /* Clock enable command */ - FMC_Bank5_6->SDCMR = 0x00000011; - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Delay */ - for (index = 0; index<1000; index++); - - /* PALL command */ - FMC_Bank5_6->SDCMR = 0x00000012; - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Auto refresh command */ - FMC_Bank5_6->SDCMR = 0x00000073; - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* MRD register program */ - FMC_Bank5_6->SDCMR = 0x00046014; - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Set refresh count */ - tmpreg = FMC_Bank5_6->SDRTR; - FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); - - /* Disable write protection */ - tmpreg = FMC_Bank5_6->SDCR[0]; - FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); -#endif /* DATA_IN_ExtSDRAM */ - -#if defined(DATA_IN_ExtSRAM) -/*-- GPIOs Configuration -----------------------------------------------------*/ - /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ - RCC->AHB1ENR |= 0x00000078; - - /* Connect PDx pins to FMC Alternate function */ - GPIOD->AFR[0] = 0x00ccc0cc; - GPIOD->AFR[1] = 0xcccccccc; - /* Configure PDx pins in Alternate function mode */ - GPIOD->MODER = 0xaaaa0a8a; - /* Configure PDx pins speed to 100 MHz */ - GPIOD->OSPEEDR = 0xffff0fcf; - /* Configure PDx pins Output type to push-pull */ - GPIOD->OTYPER = 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOD->PUPDR = 0x00000000; - - /* Connect PEx pins to FMC Alternate function */ - GPIOE->AFR[0] = 0xc00cc0cc; - GPIOE->AFR[1] = 0xcccccccc; - /* Configure PEx pins in Alternate function mode */ - GPIOE->MODER = 0xaaaa828a; - /* Configure PEx pins speed to 100 MHz */ - GPIOE->OSPEEDR = 0xffffc3cf; - /* Configure PEx pins Output type to push-pull */ - GPIOE->OTYPER = 0x00000000; - /* No pull-up, pull-down for PEx pins */ - GPIOE->PUPDR = 0x00000000; - - /* Connect PFx pins to FMC Alternate function */ - GPIOF->AFR[0] = 0x00cccccc; - GPIOF->AFR[1] = 0xcccc0000; - /* Configure PFx pins in Alternate function mode */ - GPIOF->MODER = 0xaa000aaa; - /* Configure PFx pins speed to 100 MHz */ - GPIOF->OSPEEDR = 0xff000fff; - /* Configure PFx pins Output type to push-pull */ - GPIOF->OTYPER = 0x00000000; - /* No pull-up, pull-down for PFx pins */ - GPIOF->PUPDR = 0x00000000; - - /* Connect PGx pins to FMC Alternate function */ - GPIOG->AFR[0] = 0x00cccccc; - GPIOG->AFR[1] = 0x000000c0; - /* Configure PGx pins in Alternate function mode */ - GPIOG->MODER = 0x00085aaa; - /* Configure PGx pins speed to 100 MHz */ - GPIOG->OSPEEDR = 0x000cafff; - /* Configure PGx pins Output type to push-pull */ - GPIOG->OTYPER = 0x00000000; - /* No pull-up, pull-down for PGx pins */ - GPIOG->PUPDR = 0x00000000; - -/*-- FMC/FSMC Configuration --------------------------------------------------*/ - /* Enable the FMC/FSMC interface clock */ - RCC->AHB3ENR |= 0x00000001; - -#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) - /* Configure and enable Bank1_SRAM2 */ - FMC_Bank1->BTCR[2] = 0x00001011; - FMC_Bank1->BTCR[3] = 0x00000201; - FMC_Bank1E->BWTR[2] = 0x0fffffff; -#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ - -#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) - /* Configure and enable Bank1_SRAM2 */ - FSMC_Bank1->BTCR[2] = 0x00001011; - FSMC_Bank1->BTCR[3] = 0x00000201; - FSMC_Bank1E->BWTR[2] = 0x0fffffff; -#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ - -#endif /* DATA_IN_ExtSRAM */ - -} -#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ /** * @} */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.h index 69793f9a53..2df387f856 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file system_stm32f4xx.h * @author MCD Application Team - * @version V2.0.0RC6 - * @date 03-February-2014 + * @version V2.0.0 + * @date 18-February-2014 * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. ****************************************************************************** * @attention diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/misc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/misc.c index 5107a05aea..ff3fc0906c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/misc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/misc.c @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/misc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/misc.h index f5a2b2799b..c4ce27a41c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/misc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/misc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx.h index 059f9d37c8..64edcccc85 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx.h @@ -26,19 +26,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_adc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_adc.c index 485d027642..b00431d2ca 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_adc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_adc.c @@ -65,19 +65,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_adc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_adc.h index f6b76c4b06..592cb78ce5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_adc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_adc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes.c index 81af9d6603..6a166a406e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes.c @@ -52,19 +52,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes.h index f2d00865e1..009442c98b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes_util.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes_util.c index 2dccd8b8ed..9c6ee7e6d6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes_util.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_aes_util.c @@ -30,19 +30,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_comp.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_comp.c index 1fe4351859..9d5ec08b9a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_comp.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_comp.c @@ -56,19 +56,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_comp.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_comp.h index 39135876ad..a7b0499f47 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_comp.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_comp.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_conf.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_conf.h index 873c8b1980..1de3633486 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_conf.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_conf.h @@ -8,19 +8,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2012 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_crc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_crc.c index 11f0cb4720..21b83cf3ba 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_crc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_crc.c @@ -8,19 +8,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_crc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_crc.h index adb6cf6de1..6e56eeb744 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_crc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_crc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dac.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dac.c index 978047dcdf..c2d8190d32 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dac.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dac.c @@ -83,19 +83,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dac.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dac.h index fc6b9a393f..93333d2348 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dac.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dac.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.c index 668312f68c..ab6f2ab5ef 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.c @@ -8,19 +8,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.h index 70016a506d..11991a8e62 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dbgmcu.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dma.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dma.c index d1acdd9bf8..9e65817b45 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dma.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dma.c @@ -52,19 +52,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dma.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dma.h index a80db34b2e..39bf80a55e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dma.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_dma.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_exti.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_exti.c index 5692e50810..836da8fb2d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_exti.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_exti.c @@ -45,19 +45,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_exti.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_exti.h index 364bf1068f..1d4d39d66b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_exti.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_exti.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash.c index 20ad12505c..179f66b31a 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash.c @@ -75,19 +75,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash.h index 232a228c0c..2da0f87794 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash_ramfunc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash_ramfunc.c index e3d7cf9518..e3543b4197 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash_ramfunc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_flash_ramfunc.c @@ -39,19 +39,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.c index 472860b79c..b85648eae0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.c @@ -12,19 +12,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.h index 039d65c166..248c55b7db 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_fsmc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_gpio.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_gpio.c index ab3fa0601a..0569b5dc01 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_gpio.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_gpio.c @@ -55,19 +55,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_gpio.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_gpio.h index e4b2fa6f0d..5d9fd6c054 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_gpio.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_gpio.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_i2c.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_i2c.c index 6fe845bfd9..32b284fcd4 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_i2c.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_i2c.c @@ -57,19 +57,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_i2c.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_i2c.h index 1826fab93d..6af697f68d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_i2c.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_i2c.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.c index 254844d0f6..6b38e38788 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.c @@ -64,19 +64,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.h index 4d9babffd2..8d6af16c27 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_iwdg.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_lcd.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_lcd.c index c280499beb..dc3e99f558 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_lcd.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_lcd.c @@ -61,19 +61,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_lcd.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_lcd.h index ba7184f868..c8371dacf0 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_lcd.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_lcd.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.c index 5b41ff26fb..f06cbd04bc 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.c @@ -44,19 +44,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.h index d90461c029..7f2c3e74bf 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.c index 285f560de6..4d1a86418b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.c @@ -17,19 +17,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.h index 2275a66daa..c1e311d297 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_pwr.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rcc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rcc.c index 58f3bcebc3..b7567cf3cf 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rcc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rcc.c @@ -38,19 +38,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rcc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rcc.h index 2b2d76ed65..6bcdade217 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rcc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rcc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rtc.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rtc.c index 94cfc0cc36..bc9853a947 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rtc.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rtc.c @@ -204,19 +204,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rtc.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rtc.h index 5f4c6ddf3d..9898ad6d48 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rtc.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_rtc.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.c index f870462788..2d44776b3e 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.c @@ -109,19 +109,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.h index 115509684e..a41d9e66ce 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_sdio.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_spi.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_spi.c index e835a97ab9..7280e0c722 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_spi.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_spi.c @@ -75,19 +75,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_spi.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_spi.h index f0237d1a89..fcc0a2f45c 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_spi.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_spi.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.c index 760e540733..ce55e41e8f 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.c @@ -49,19 +49,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.h index 3cfd7de116..26e5b1e204 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_tim.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_tim.c index 3efcf44de4..8da4010b8b 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_tim.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_tim.c @@ -89,19 +89,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_tim.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_tim.h index 3c17302efb..9550426775 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_tim.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_tim.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_usart.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_usart.c index ada526efce..c204461071 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_usart.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_usart.c @@ -58,19 +58,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_usart.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_usart.h index 78d9ff9b26..d6e8dc6569 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_usart.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_usart.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.c index 4dbf25b56d..7fde06a0d6 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.c @@ -65,19 +65,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.h index e9088eb0aa..3583500d7d 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_wwdg.h @@ -9,19 +9,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2014 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/system_stm32l1xx.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/system_stm32l1xx.c index 58dddec7d2..4f2247cab8 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/system_stm32l1xx.c +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/system_stm32l1xx.c @@ -72,19 +72,29 @@ *============================================================================= * @attention * - *

© COPYRIGHT 2013 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/system_stm32l1xx.h b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/system_stm32l1xx.h index 25ad240969..4240531ca5 100644 --- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/system_stm32l1xx.h +++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/system_stm32l1xx.h @@ -8,19 +8,29 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2013 STMicroelectronics

+ *

© COPYRIGHT(c) 2014 STMicroelectronics

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/PinNames.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/PinNames.h index 00559e57a9..8e625626e1 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/PinNames.h @@ -240,6 +240,7 @@ typedef enum { PullNone = 0, PullDown = 2, PullUp = 3, + PullDefault = PullUp } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_api.c index acfbcbdc4d..111340ba57 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/gpio_api.c @@ -21,7 +21,7 @@ uint32_t gpio_set(PinName pin) { return 1 << ((pin & 0x7F) >> 2); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; @@ -35,16 +35,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = ®->PCOR; obj->reg_in = ®->PDIR; obj->reg_dir = ®->PDDR; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: - pin_mode(pin, PullNone); - break; - case PIN_INPUT : - pin_mode(pin, PullUp); - break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/PinNames.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/PinNames.h index 3f067f8c0e..8c4bb171bc 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/PinNames.h @@ -111,10 +111,13 @@ typedef enum { A3 = PTA0, A4 = PTA9, A5 = PTB13, - + I2C_SCL = D15, I2C_SDA = D14, + TSI_ELEC0 = PTA13, + TSI_ELEC1 = PTB12, + // Not connected NC = (int)0xFFFFFFFF } PinName; @@ -123,6 +126,7 @@ typedef enum { typedef enum { PullNone = 0, PullUp = 2, + PullDefault = PullUp } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/gpio_irq_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/gpio_irq_api.c index 30bf18a3fd..65ade870ec 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/gpio_irq_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/gpio_irq_api.c @@ -17,6 +17,7 @@ #include "cmsis.h" #include "gpio_irq_api.h" +#include "gpio_api.h" #include "error.h" #define CHANNEL_NUM 64 // 31 pins on 2 ports @@ -176,9 +177,8 @@ void gpio_irq_disable(gpio_irq_t *obj) { // Change the NMI pin to an input. This allows NMI pin to // be used as a low power mode wakeup. The application will // need to change the pin back to NMI_b or wakeup only occurs once! -extern void gpio_init(gpio_t *obj, PinName pin, PinDirection direction); void NMI_Handler(void) { gpio_t gpio; - gpio_init(&gpio, PTB5, PIN_INPUT); + gpio_init_in(&gpio, PTA4); } diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/PeripheralPins.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/PeripheralPins.c index 629fc49828..ef77ff1882 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/PeripheralPins.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/PeripheralPins.c @@ -19,7 +19,7 @@ /************RTC***************/ const PinMap PinMap_RTC[] = { - {PTC1, RTC_CLKIN, 2}, + {PTC1, RTC_CLKIN, 1}, }; /************ADC***************/ diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/PinNames.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/PinNames.h index 112bd01586..89ebb11aec 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/PinNames.h @@ -229,10 +229,13 @@ typedef enum { A3 = PTB3, A4 = PTC2, A5 = PTC1, - + I2C_SCL = D15, I2C_SDA = D14, + TSI_ELEC0 = PTB16, + TSI_ELEC1 = PTB17, + // Not connected NC = (int)0xFFFFFFFF } PinName; @@ -241,6 +244,7 @@ typedef enum { typedef enum { PullNone = 0, PullUp = 2, + PullDefault = PullUp } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/gpio_irq_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/gpio_irq_api.c index e3f704da4c..e871474c05 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/gpio_irq_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/gpio_irq_api.c @@ -17,6 +17,7 @@ #include "cmsis.h" #include "gpio_irq_api.h" +#include "gpio_api.h" #include "error.h" #define CHANNEL_NUM 64 @@ -166,9 +167,8 @@ void gpio_irq_disable(gpio_irq_t *obj) { // Change the NMI pin to an input. This allows NMI pin to // be used as a low power mode wakeup. The application will // need to change the pin back to NMI_b or wakeup only occurs once! -extern void gpio_init(gpio_t *obj, PinName pin, PinDirection direction); void NMI_Handler(void) { gpio_t gpio; - gpio_init(&gpio, PTA4, PIN_INPUT); + gpio_init_in(&gpio, PTA4); } diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/PeripheralPins.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/PeripheralPins.c index 37d96d040a..58057d178a 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/PeripheralPins.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/PeripheralPins.c @@ -18,7 +18,7 @@ /************RTC***************/ const PinMap PinMap_RTC[] = { - {PTC1, RTC_CLKIN, 2}, + {PTC1, RTC_CLKIN, 1}, }; /************ADC***************/ diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/PinNames.h b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/PinNames.h index 5ca0d1517f..d5bb7bded8 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/PinNames.h @@ -199,11 +199,11 @@ typedef enum { LED2 = LED_RED, LED3 = LED_GREEN, LED4 = LED_RED, - + //Push buttons SW1 = PTC3, SW3 = PTC12, - + // USB Pins USBTX = PTA2, USBRX = PTA1, @@ -232,10 +232,13 @@ typedef enum { A3 = PTB3, A4 = PTC2, A5 = PTC1, - + I2C_SCL = D15, I2C_SDA = D14, + TSI_ELEC0 = PTB16, + TSI_ELEC1 = PTB17, + // Not connected NC = (int)0xFFFFFFFF } PinName; @@ -244,7 +247,8 @@ typedef enum { typedef enum { PullNone = 0, PullDown = 2, - PullUp = 3 + PullUp = 3, + PullDefault = PullUp } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/gpio_irq_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/gpio_irq_api.c index e4b3de004a..e32f2b4177 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/gpio_irq_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/gpio_irq_api.c @@ -17,6 +17,7 @@ #include "cmsis.h" #include "gpio_irq_api.h" +#include "gpio_api.h" #include "error.h" #define CHANNEL_NUM 96 @@ -186,9 +187,8 @@ void gpio_irq_disable(gpio_irq_t *obj) { // Change the NMI pin to an input. This allows NMI pin to // be used as a low power mode wakeup. The application will // need to change the pin back to NMI_b or wakeup only occurs once! -extern void gpio_init(gpio_t *obj, PinName pin, PinDirection direction); void NMI_Handler(void) { gpio_t gpio; - gpio_init(&gpio, PTA4, PIN_INPUT); + gpio_init_in(&gpio, PTA4); } diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_api.c index dc40326281..8341b5d029 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/gpio_api.c @@ -21,7 +21,7 @@ uint32_t gpio_set(PinName pin) { return 1 << ((pin & 0x7F) >> 2); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == (PinName)NC) return; obj->pin = pin; @@ -34,12 +34,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = ®->PCOR; obj->reg_in = ®->PDIR; obj->reg_dir = ®->PDDR; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullUp); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h index e021868fed..031b2ad26a 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/PinNames.h @@ -142,7 +142,8 @@ typedef enum { typedef enum { PullNone = 0, PullDown = 1, - PullUp = 3 + PullUp = 3, + PullDefault = PullUp } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_api.c index 1049a55558..9804d8748c 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_NRF51822/gpio_api.c @@ -16,7 +16,7 @@ #include "gpio_api.h" #include "pinmap.h" -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; obj->pin = pin; @@ -26,12 +26,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &NRF_GPIO->OUTCLR; obj->reg_in = &NRF_GPIO->IN; obj->reg_dir = &NRF_GPIO->DIR; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullUp); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U24_301/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U24_301/PinNames.h index 4e45c040b7..6688e3caff 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U24_301/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U24_301/PinNames.h @@ -155,7 +155,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U24_401/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U24_401/PinNames.h index 4e45c040b7..19c40a27ab 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U24_401/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U24_401/PinNames.h @@ -135,6 +135,29 @@ typedef enum { USBTX = P0_19, USBRX = P0_18, + // for Arch V1.1 + D0 = P0_18, + D1 = P0_19, + D2 = P0_17, + D3 = P1_17, + D4 = P1_18, + D5 = P1_24, + D6 = P1_25, + D7 = P1_5, + D8 = P1_26, + D9 = P1_27, + D10 = P0_2, + D11 = P0_9, // P1_29 for Arch V1.0 + D12 = P0_8, + D13 = P1_29, // P0_9 for Arch V1.0 + + A0 = P0_11, + A1 = P0_12, + A2 = P0_13, + A3 = P0_14, + A4 = P0_16, + A5 = P0_22, + // Not connected NC = (int)0xFFFFFFFF, } PinName; @@ -155,7 +178,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_401/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_401/PinNames.h index 09552ec07d..9ec905f121 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_401/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_401/PinNames.h @@ -150,7 +150,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/PeripheralNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/PeripheralNames.h new file mode 100644 index 0000000000..969f15f2f6 --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/PeripheralNames.h @@ -0,0 +1,71 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 MBED_PERIPHERALNAMES_H +#define MBED_PERIPHERALNAMES_H + +#include "cmsis.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + UART_0 = (int)LPC_USART_BASE +} UARTName; + +typedef enum { + I2C_0 = (int)LPC_I2C_BASE +} I2CName; + +typedef enum { + ADC0_0 = 0, + ADC0_1, + ADC0_2, + ADC0_3, + ADC0_4, + ADC0_5, + ADC0_6, + ADC0_7 +} ADCName; + +typedef enum { + SPI_0 = (int)LPC_SSP0_BASE, + SPI_1 = (int)LPC_SSP1_BASE +} SPIName; + +typedef enum { + PWM_1 = 0, + PWM_2, + PWM_3, + PWM_4, + PWM_5, + PWM_6, + PWM_7, + PWM_8, + PWM_9, + PWM_10, + PWM_11 +} PWMName; + +#define STDIO_UART_TX UART_TX +#define STDIO_UART_RX UART_RX +#define STDIO_UART UART_0 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/PinNames.h new file mode 100644 index 0000000000..6f20b537b5 --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/PinNames.h @@ -0,0 +1,176 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 MBED_PINNAMES_H +#define MBED_PINNAMES_H + +#include "cmsis.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + PIN_INPUT, + PIN_OUTPUT +} PinDirection; + +#define PORT_SHIFT 5 + +typedef enum { + // LPC11U Pin Names + P0_0 = 0, + P0_1 = 1, + P0_2 = 2, + P0_3 = 3, + P0_4 = 4, + P0_5 = 5, + P0_6 = 6, + P0_7 = 7, + P0_8 = 8, + P0_9 = 9, + P0_10 = 10, + P0_11 = 11, + P0_12 = 12, + P0_13 = 13, + P0_14 = 14, + P0_15 = 15, + P0_16 = 16, + P0_17 = 17, + P0_18 = 18, + P0_19 = 19, + P0_20 = 20, + P0_21 = 21, + P0_22 = 22, + P0_23 = 23, + P0_24 = 24, + P0_25 = 25, + P0_26 = 26, + P0_27 = 27, + + P1_0 = 32, + P1_1 = 33, + P1_2 = 34, + P1_3 = 35, + P1_4 = 36, + P1_5 = 37, + P1_6 = 38, + P1_7 = 39, + P1_8 = 40, + P1_9 = 41, + P1_10 = 42, + P1_11 = 43, + P1_12 = 44, + P1_13 = 45, + P1_14 = 46, + P1_15 = 47, + P1_16 = 48, + P1_17 = 49, + P1_18 = 50, + P1_19 = 51, + P1_20 = 52, + P1_21 = 53, + P1_22 = 54, + P1_23 = 55, + P1_24 = 56, + P1_25 = 57, + P1_26 = 58, + P1_27 = 59, + P1_28 = 60, + P1_29 = 61, + + P1_31 = 63, + + // mbed DIP Pin Names + // CN1-1 (GND) + // CN1-2 (EXTPOWER) + // CN1-3 (NC) + p4 = P0_0, // CN1-4 + p5 = P0_9, // CN1-5 + p6 = P0_8, // CN1-6 + p7 = P0_10, // CN1-7 + p8 = P0_7, // CN1-8 + p9 = P0_19, // CN1-9 + p10 = P0_18, // CN1-10 + p11 = P0_21, // CN1-11 + p12 = P0_22, // CN1-12 + p13 = P1_15, // CN1-13 + p14 = P0_6, // CN1-14 + p15 = P0_11, // CN1-15 + p16 = P0_12, // CN1-16 + p17 = P0_13, // CN1-17 + p18 = P0_14, // CN1-18 + p19 = P0_15, // CN1-19 + p20 = P0_16, // CN1-20 + + p21 = P0_14, // CN2-20 + p22 = P0_2, // CN2-19 + p23 = P0_23, // CN2-18 + p24 = P0_17, // CN2-17 + p25 = P0_20, // CN2-16 + p26 = P1_15, // CN2-15 + p27 = P0_4, // CN2-14 + p28 = P0_5, // CN2-13 + p29 = P1_19, // CN2-12 + p30 = P0_1, // CN2-11 + // CN2-10 (D+USB) + // CN2-9 (D-USB) + p33 = P0_3, // CN2-8 (USB-VBUS) + // CN2-7 (NC) + // CN2-6 (NC) + // CN2-5 (NC) + // CN2-4 (NC) + // CN2-3 (NC) + // CN2-2 (VDD) + // CN2-1 (VDD) + + // Other mbed Pin Names + LED1 = P0_20, + LED2 = P0_21, + LED3 = P0_20, + LED4 = P0_21, + + UART_TX = P0_19, + UART_RX = P0_18, + + // Not connected + NC = (int)0xFFFFFFFF, +} PinName; + +typedef enum { + CHANNEL0 = FLEX_INT0_IRQn, + CHANNEL1 = FLEX_INT1_IRQn, + CHANNEL2 = FLEX_INT2_IRQn, + CHANNEL3 = FLEX_INT3_IRQn, + CHANNEL4 = FLEX_INT4_IRQn, + CHANNEL5 = FLEX_INT5_IRQn, + CHANNEL6 = FLEX_INT6_IRQn, + CHANNEL7 = FLEX_INT7_IRQn +} Channel; + +typedef enum { + PullUp = 2, + PullDown = 1, + PullNone = 0, + Repeater = 3, + OpenDrain = 4, + PullDefault = PullDown +} PinMode; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/device.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/device.h new file mode 100644 index 0000000000..120ca9edb6 --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_501/device.h @@ -0,0 +1,59 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 MBED_DEVICE_H +#define MBED_DEVICE_H + +#define DEVICE_PORTIN 1 +#define DEVICE_PORTOUT 1 +#define DEVICE_PORTINOUT 1 + +#define DEVICE_INTERRUPTIN 1 + +#define DEVICE_ANALOGIN 1 +#define DEVICE_ANALOGOUT 0 + +#define DEVICE_SERIAL 1 + +#define DEVICE_I2C 1 +#define DEVICE_I2CSLAVE 1 + +#define DEVICE_SPI 1 +#define DEVICE_SPISLAVE 1 + +#define DEVICE_CAN 0 + +#define DEVICE_RTC 0 + +#define DEVICE_ETHERNET 0 + +#define DEVICE_PWMOUT 1 + +#define DEVICE_SEMIHOST 0 +#define DEVICE_LOCALFILESYSTEM 0 +#define DEVICE_ID_LENGTH 32 +#define DEVICE_MAC_OFFSET 20 + +#define DEVICE_SLEEP 1 + +#define DEVICE_DEBUG_AWARENESS 0 + +#define DEVICE_STDIO_MESSAGES 0 + +#define DEVICE_ERROR_PATTERN 1 + +#include "objects.h" + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c index 1488ab895b..fc1120afde 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.c @@ -27,7 +27,7 @@ uint32_t gpio_set(PinName pin) { return (1 << ((int)pin & 0x1F)); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; obj->pin = pin; @@ -39,12 +39,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &LPC_GPIO->CLR[port]; obj->reg_in = &LPC_GPIO->PIN[port]; obj->reg_dir = &LPC_GPIO->DIR[port]; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/PinNames.h index 10db604450..d99c0de8db 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/PinNames.h @@ -208,7 +208,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11XX/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11XX/PinNames.h index b0e61f7547..25b3bf9a3b 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11XX/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11XX/PinNames.h @@ -223,7 +223,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_api.c index 60610ac90e..e899331579 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/gpio_api.c @@ -34,7 +34,7 @@ uint32_t gpio_set(PinName pin) { return ((pin & 0x0F00) >> 8); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; obj->pin = pin; @@ -43,13 +43,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_mask_read = &port_reg->MASKED_ACCESS[1 << gpio_set(pin)]; obj->reg_dir = &port_reg->DIR; obj->reg_write = &port_reg->DATA; - - gpio_dir(obj, direction); - - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/PinNames.h index 3fa5e9f635..3f528558a3 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/PinNames.h @@ -140,7 +140,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c index 1488ab895b..fc1120afde 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/gpio_api.c @@ -27,7 +27,7 @@ uint32_t gpio_set(PinName pin) { return (1 << ((int)pin & 0x1F)); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; obj->pin = pin; @@ -39,12 +39,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &LPC_GPIO->CLR[port]; obj->reg_in = &LPC_GPIO->PIN[port]; obj->reg_dir = &LPC_GPIO->DIR[port]; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/PeripheralNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/PeripheralNames.h index 9cbce7807a..742d7a7818 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/PeripheralNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/PeripheralNames.h @@ -49,6 +49,9 @@ typedef enum { ADC1_11, } ADCName; +typedef enum { + DAC0_0 = 0, +} DACName; #ifdef __cplusplus } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/PinNames.h index 90ffc04c5e..1a8a873251 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/PinNames.h @@ -81,7 +81,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #define STDIO_UART_TX USBTX diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogout_api.c new file mode 100644 index 0000000000..e2c6acf9ef --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/analogout_api.c @@ -0,0 +1,73 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ +#include "analogout_api.h" +#include "cmsis.h" +#include "pinmap.h" +#include "error.h" + +void analogout_init(dac_t *obj, PinName pin) { + if (pin != P0_12) { + error("DAC pin mapping failed"); + } + + LPC_SYSCON->SYSAHBCLKCTRL0 |= (1 << 29); + LPC_SYSCON->PDRUNCFG &= ~(1 << 12); + LPC_IOCON->PIO0_12 = 0; + LPC_SWM->PINENABLE0 &= ~(1 << 24); + LPC_DAC->CTRL = 0; + + analogout_write_u16(obj, 0); +} + +void analogout_free(dac_t *obj) +{ + LPC_SYSCON->SYSAHBCLKCTRL0 &= ~(1 << 29); + LPC_SWM->PINENABLE0 |= (1 << 24); +} + +static inline void dac_write(int value) { + value &= 0xFFF; // 12-bit + + // Set the DAC output + LPC_DAC->VAL = (value << 4); +} + +static inline int dac_read() { + return ((LPC_DAC->VAL >> 4) & 0xFFF); +} + +void analogout_write(dac_t *obj, float value) { + if (value < 0.0f) { + dac_write(0); + } else if (value > 1.0f) { + dac_write(0xFFF); + } else { + dac_write((uint32_t)(value * (float)0xFFF)); + } +} + +void analogout_write_u16(dac_t *obj, uint16_t value) { + dac_write(value); +} + +float analogout_read(dac_t *obj) { + uint32_t value = dac_read(); + return (float)value * (1.0f / (float)0xFFF); +} + +uint16_t analogout_read_u16(dac_t *obj) { + return (uint16_t)dac_read(); +} diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/device.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/device.h index f1b1a4e03c..b49c645971 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/device.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/device.h @@ -23,7 +23,7 @@ #define DEVICE_INTERRUPTIN 1 #define DEVICE_ANALOGIN 1 -#define DEVICE_ANALOGOUT 0 +#define DEVICE_ANALOGOUT 1 #define DEVICE_SERIAL 1 #define DEVICE_SERIAL_FC 1 @@ -40,7 +40,7 @@ #define DEVICE_ETHERNET 0 -#define DEVICE_PWMOUT 0 +#define DEVICE_PWMOUT 1 #define DEVICE_SEMIHOST 0 #define DEVICE_LOCALFILESYSTEM 0 diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c index f974e782a5..f16536b1e6 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/gpio_api.c @@ -33,7 +33,7 @@ uint32_t gpio_set(PinName pin) { return (1UL << ((int)pin & 0x1f)); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; obj->pin = pin; @@ -45,12 +45,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &LPC_GPIO_PORT->CLR[port]; obj->reg_in = &LPC_GPIO_PORT->PIN[port]; obj->reg_dir = &LPC_GPIO_PORT->DIR[port]; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c index 51d5ca6ee3..394b65ae89 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/i2c_api.c @@ -29,7 +29,7 @@ static inline int i2c_status(i2c_t *obj) { // Wait until the Serial Interrupt (SI) is set static int i2c_wait_SI(i2c_t *obj) { - int timeout = 0; + volatile int timeout = 0; while (!(LPC_I2C0->STAT & (1 << 0))) { timeout++; if (timeout > 100000) return -1; @@ -41,25 +41,21 @@ static inline void i2c_interface_enable(i2c_t *obj) { LPC_I2C0->CFG |= (1 << 0); } -static inline void i2c_power_enable(i2c_t *obj) { - // Enables clock for I2C0 - LPC_SYSCON->SYSAHBCLKCTRL1 |= (1<<13); -// LPC_SYSCON->PRESETCTRL1 &= ~(0x1<<13); - LPC_SYSCON->PRESETCTRL1 |= (0x1<<13); - LPC_SYSCON->PRESETCTRL1 &= ~(0x1 << 13); - -} - void i2c_init(i2c_t *obj, PinName sda, PinName scl) { + if ((sda != P0_23) | (scl != P0_22)) { + error("I2C pin mapping failed"); + } - // ƒsƒ“’è‹`‚ÌŠm”F‚Ç‚¤‚µ‚悤c - - - // enable power - i2c_power_enable(obj); + // Enables clock for I2C0 + LPC_SYSCON->SYSAHBCLKCTRL1 |= (1 << 13); + + LPC_SYSCON->PRESETCTRL1 |= (1 << 13); + LPC_SYSCON->PRESETCTRL1 &= ~(1 << 13); + // pin enable LPC_SWM->PINENABLE1 &= ~(0x3 << 3); - // set default frequency at 100k + + // set default frequency at 100kHz i2c_frequency(obj, 100000); i2c_interface_enable(obj); } @@ -76,7 +72,7 @@ inline int i2c_start(i2c_t *obj) { } inline int i2c_stop(i2c_t *obj) { - int timeout = 0; + volatile int timeout = 0; LPC_I2C0->MSTCTL = (1 << 2) | (1 << 0); while ((LPC_I2C0->STAT & ((1 << 0) | (7 << 1))) != ((1 << 0) | (0 << 1))) { @@ -107,14 +103,12 @@ static inline int i2c_do_read(i2c_t *obj, int last) { LPC_I2C0->MSTCTL = (1 << 0); // return the data - //return (I2C_DAT(obj) & 0xFF); return (LPC_I2C0->MSTDAT & 0xFF); } void i2c_frequency(i2c_t *obj, int hz) { // No peripheral clock divider on the M0 uint32_t PCLK = SystemCoreClock; - uint32_t clkdiv = PCLK / (hz * 4) - 1; LPC_I2C0->DIV = clkdiv; @@ -123,19 +117,15 @@ void i2c_frequency(i2c_t *obj, int hz) { int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { int count, status; - int timeout = 0; i2c_start(obj); - //status = i2c_do_write(obj, (address | 0x01), 1); LPC_I2C0->MSTDAT = (address | 0x01); LPC_I2C0->MSTCTL |= 0x20; - while (!(LPC_I2C0->STAT & (1 << 0))) { - timeout++; - if (timeout > 100000) return -1; - } + if (i2c_wait_SI(obj) == -1) + return -1; + status = ((LPC_I2C0->STAT >> 1) & (0x07)); - if (status != 0x01) { i2c_stop(obj); return I2C_ERROR_NO_SLAVE; @@ -143,39 +133,27 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { // Read in all except last byte for (count = 0; count < (length - 1); count++) { - //int value = i2c_do_read(obj, 0); - while (!(LPC_I2C0->STAT & (1 << 0))) { - timeout++; - if (timeout > 100000) return -1; - } - if (!0) - LPC_I2C0->MSTCTL = (1 << 0); - data[count] = (LPC_I2C0->MSTDAT & 0xFF); - // - status = ((LPC_I2C0->STAT >> 1) & (0x07)); + if (i2c_wait_SI(obj) == -1) + return -1; + LPC_I2C0->MSTCTL = (1 << 0); + data[count] = (LPC_I2C0->MSTDAT & 0xFF); + status = ((LPC_I2C0->STAT >> 1) & (0x07)); if (status != 0x00) { i2c_stop(obj); return count; } - //data[count] = (char) value; } // read in last byte - //int value = i2c_do_read(obj, 1); - while (!(LPC_I2C0->STAT & (1 << 0))) { - timeout++; - if (timeout > 100000) return -1; - } + if (i2c_wait_SI(obj) == -1) + return -1; + data[count] = (LPC_I2C0->MSTDAT & 0xFF); - // status = i2c_status(obj); if (status != 0x01) { i2c_stop(obj); return length - 1; } - - //data[count] = (char) value; - // If not repeated start, send stop. if (stop) { i2c_stop(obj); @@ -188,35 +166,27 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) { int i, status; - int timeout = 0; i2c_start(obj); - //status = i2c_do_write(obj, (address & 0xFE), 1); LPC_I2C0->MSTDAT = (address & 0xFE); LPC_I2C0->MSTCTL |= 0x20; - // wait and return status - while (!(LPC_I2C0->STAT & (1 << 0))) { - timeout++; - if (timeout > 100000) return -1; - } + if (i2c_wait_SI(obj) == -1) + return -1; + status = ((LPC_I2C0->STAT >> 1) & (0x07)); - if (status != 0x02) { i2c_stop(obj); return I2C_ERROR_NO_SLAVE; } for (i=0; iMSTDAT = data[i]; LPC_I2C0->MSTCTL = (1 << 0); - // wait and return status - while (!(LPC_I2C0->STAT & (1 << 0))) { - timeout++; - if (timeout > 100000) return -1; - } - status = ((LPC_I2C0->STAT >> 1) & (0x07)); + if (i2c_wait_SI(obj) == -1) + return -1; + + status = ((LPC_I2C0->STAT >> 1) & (0x07)); if (status != 0x02) { i2c_stop(obj); return i; @@ -242,17 +212,9 @@ int i2c_byte_read(i2c_t *obj, int last) { } int i2c_byte_write(i2c_t *obj, int data) { - int ack; - int status = i2c_do_write(obj, (data & 0xFF), 0); - - switch(status) { - case 2: - ack = 1; - break; - default: - ack = 0; - break; + if (i2c_do_write(obj, (data & 0xFF), 0) == 2) { + return 1; + } else { + return 0; } - - return ack; } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/objects.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/objects.h index ff9c2a53b3..edbb15105b 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/objects.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/objects.h @@ -29,6 +29,11 @@ struct gpio_irq_s { uint32_t ch; }; +struct pwmout_s { + LPC_SCT0_Type* pwm; + uint32_t pwm_ch; +}; + struct serial_s { LPC_USART0_Type *uart; unsigned char index; @@ -38,6 +43,10 @@ struct analogin_s { ADCName adc; }; +struct dac_s { + DACName dac; +}; + struct i2c_s { LPC_I2C0_Type *i2c; }; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c new file mode 100644 index 0000000000..2ebcf155ba --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c @@ -0,0 +1,173 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + +#include "pwmout_api.h" +#include "cmsis.h" +#include "pinmap.h" +#include "error.h" + +static LPC_SCT0_Type *SCTs[4] = { + (LPC_SCT0_Type*)LPC_SCT0, + (LPC_SCT0_Type*)LPC_SCT1, + (LPC_SCT0_Type*)LPC_SCT2, + (LPC_SCT0_Type*)LPC_SCT3, +}; + +// bit flags for used SCTs +static unsigned char sct_used = 0; +static int get_available_sct(void) { + int i; + for (i=0; i<4; i++) { + if ((sct_used & (1 << i)) == 0) + return i; + } + return -1; +} + +void pwmout_init(pwmout_t* obj, PinName pin) { + if (pin == (uint32_t)NC) + error("PwmOut pin mapping failed"); + + int sct_n = get_available_sct(); + if (sct_n == -1) { + error("No available SCT"); + } + + sct_used |= (1 << sct_n); + obj->pwm = SCTs[sct_n]; + obj->pwm_ch = sct_n; + + LPC_SCT0_Type* pwm = obj->pwm; + + // Enable the SCT clock + LPC_SYSCON->SYSAHBCLKCTRL1 |= (1 << (obj->pwm_ch + 2)); + + // Clear peripheral reset the SCT: + LPC_SYSCON->PRESETCTRL1 |= (1 << (obj->pwm_ch + 2)); + LPC_SYSCON->PRESETCTRL1 &= ~(1 << (obj->pwm_ch + 2)); + + switch(obj->pwm_ch) { + case 0: + // SCT0_OUT0 + LPC_SWM->PINASSIGN[7] &= ~0x0000FF00; + LPC_SWM->PINASSIGN[7] |= (pin << 8); + break; + case 1: + // SCT1_OUT0 + LPC_SWM->PINASSIGN[8] &= ~0x000000FF; + LPC_SWM->PINASSIGN[8] |= (pin); + break; + case 2: + // SCT2_OUT0 + LPC_SWM->PINASSIGN[8] &= ~0xFF000000; + LPC_SWM->PINASSIGN[8] |= (pin << 24); + break; + case 3: + // SCT3_OUT0 + LPC_SWM->PINASSIGN[9] &= ~0x00FF0000; + LPC_SWM->PINASSIGN[9] |= (pin << 16); + break; + default: + break; + } + + // Two 16-bit counters, autolimit + pwm->CONFIG &= ~(0x1); + pwm->CONFIG |= (1 << 17); + + // halt and clear the counter + pwm->CTRL |= (1 << 2) | (1 << 3); + + // System Clock -> us_ticker (1)MHz + pwm->CTRL &= ~(0x7F << 5); + pwm->CTRL |= (((SystemCoreClock/1000000 - 1) & 0x7F) << 5); + + // Match reload register + pwm->MATCHREL0 = 20000; // 20ms + pwm->MATCHREL1 = (pwm->MATCHREL0 / 4); // 50% duty + + pwm->OUT0_SET = (1 << 0); // event 0 + pwm->OUT0_CLR = (1 << 1); // event 1 + + pwm->EV0_CTRL = (1 << 12); + pwm->EV0_STATE = 0xFFFFFFFF; + pwm->EV1_CTRL = (1 << 12) | (1 << 0); + pwm->EV1_STATE = 0xFFFFFFFF; + + // unhalt the counter: + // - clearing bit 2 of the CTRL register + pwm->CTRL &= ~(1 << 2); + + // default to 20ms: standard for servos, and fine for e.g. brightness control + pwmout_period_ms(obj, 20); + pwmout_write (obj, 0); +} + +void pwmout_free(pwmout_t* obj) { + // Disable the SCT clock + LPC_SYSCON->SYSAHBCLKCTRL1 &= ~(1 << (obj->pwm_ch + 2)); + sct_used &= ~(1 << obj->pwm_ch); +} + +void pwmout_write(pwmout_t* obj, float value) { + LPC_SCT0_Type* pwm = obj->pwm; + if (value < 0.0f) { + value = 0.0; + } else if (value > 1.0f) { + value = 1.0; + } + uint32_t t_off = pwm->MATCHREL0 - (uint32_t)((float)(pwm->MATCHREL0) * value); + uint32_t t_on = (uint32_t)((float)(pwm->MATCHREL0) * value); + pwm->MATCHREL1 = t_on; +} + +float pwmout_read(pwmout_t* obj) { + uint32_t t_off = obj->pwm->MATCHREL0; + uint32_t t_on = obj->pwm->MATCHREL1; + float v = (float)t_on/(float)t_off; + return (v > 1.0f) ? (1.0f) : (v); +} + +void pwmout_period(pwmout_t* obj, float seconds) { + pwmout_period_us(obj, seconds * 1000000.0f); +} + +void pwmout_period_ms(pwmout_t* obj, int ms) { + pwmout_period_us(obj, ms * 1000); +} + +// Set the PWM period, keeping the duty cycle the same. +void pwmout_period_us(pwmout_t* obj, int us) { + LPC_SCT0_Type* pwm = obj->pwm; + uint32_t t_off = pwm->MATCHREL0; + uint32_t t_on = pwm->MATCHREL1; + float v = (float)t_on/(float)t_off; + pwm->MATCHREL0 = (uint64_t)us; + pwm->MATCHREL1 = (uint64_t)((float)us * (float)v); +} + +void pwmout_pulsewidth(pwmout_t* obj, float seconds) { + pwmout_pulsewidth_us(obj, seconds * 1000000.0f); +} + +void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) { + pwmout_pulsewidth_us(obj, ms * 1000); +} + +void pwmout_pulsewidth_us(pwmout_t* obj, int us) { + obj->pwm->MATCHREL1 = (uint64_t)us; +} + diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/us_ticker.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/us_ticker.c index 1954a7d612..005188578b 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/us_ticker.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC15XX/us_ticker.c @@ -17,7 +17,7 @@ #include "us_ticker_api.h" #include "PeripheralNames.h" -#define US_TICKER_TIMER_IRQn SCT0_IRQn +#define US_TICKER_TIMER_IRQn RIT_IRQn int us_ticker_inited = 0; @@ -25,25 +25,24 @@ void us_ticker_init(void) { if (us_ticker_inited) return; us_ticker_inited = 1; - // Enable the SCT0 clock - LPC_SYSCON->SYSAHBCLKCTRL1 |= (1 << 2); + // Enable the RIT clock + LPC_SYSCON->SYSAHBCLKCTRL1 |= (1 << 1); - // Clear peripheral reset the SCT0: - LPC_SYSCON->PRESETCTRL1 |= (1 << 2); - LPC_SYSCON->PRESETCTRL1 &= ~(1 << 2); + // Clear peripheral reset the RIT + LPC_SYSCON->PRESETCTRL1 |= (1 << 1); + LPC_SYSCON->PRESETCTRL1 &= ~(1 << 1); - // Unified counter (32 bits) - LPC_SCT0->CONFIG |= 1; + LPC_RIT->MASK = 0; + LPC_RIT->MASK_H = 0; - // halt and clear the counter - LPC_SCT0->CTRL |= (1 << 2) | (1 << 3); - - // System Clock (12)MHz -> us_ticker (1)MHz - LPC_SCT0->CTRL |= ((SystemCoreClock/1000000 - 1) << 5); - - // unhalt the counter: - // - clearing bit 2 of the CTRL register - LPC_SCT0->CTRL &= ~(1 << 2); + LPC_RIT->COUNTER = 0; + LPC_RIT->COUNTER_H = 0; + + LPC_RIT->COMPVAL = 0xffffffff; + LPC_RIT->COMPVAL_H = 0x0000ffff; + + // Timer enable, enable for debug + LPC_RIT->CTRL = 0xC; NVIC_SetVector(US_TICKER_TIMER_IRQn, (uint32_t)us_ticker_irq_handler); NVIC_EnableIRQ(US_TICKER_TIMER_IRQn); @@ -53,42 +52,22 @@ uint32_t us_ticker_read() { if (!us_ticker_inited) us_ticker_init(); - return LPC_SCT0->COUNT; + uint64_t temp; + temp = LPC_RIT->COUNTER | ((uint64_t)LPC_RIT->COUNTER_H << 32); + temp /= (SystemCoreClock/1000000); + return (uint32_t)temp; } void us_ticker_set_interrupt(unsigned int timestamp) { - // halt the counter: - // - setting bit 2 of the CTRL register - LPC_SCT0->CTRL |= (1 << 2); - - // set timestamp in compare register - LPC_SCT0->MATCH0 = timestamp; - - // unhalt the counter: - // - clearing bit 2 of the CTRL register - LPC_SCT0->CTRL &= ~(1 << 2); - - // if events are not enabled, enable them - if (!(LPC_SCT0->EVEN & 0x01)) { - - // comb mode = match only - LPC_SCT0->EV0_CTRL = (1 << 12); - - // ref manual: - // In simple applications that do not - // use states, write 0x01 to this - // register to enable an event - LPC_SCT0->EV0_STATE |= 0x1; - - // enable events - LPC_SCT0->EVEN |= 0x1; - } + uint64_t temp = ((uint64_t)timestamp * (SystemCoreClock/1000000)); + LPC_RIT->COMPVAL = (temp & 0xFFFFFFFFL); + LPC_RIT->COMPVAL_H = ((temp >> 32)& 0x0000FFFFL); } void us_ticker_disable_interrupt(void) { - LPC_SCT0->EVEN &= ~1; + LPC_RIT->CTRL |= (1 << 3); } void us_ticker_clear_interrupt(void) { - LPC_SCT0->EVFLAG = 1; + LPC_RIT->CTRL |= (1 << 0); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/PinNames.h index 340efd7630..82a764366c 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/PinNames.h @@ -81,6 +81,29 @@ typedef enum { USBTX = P0_2, USBRX = P0_3, + // Arch Pro Pin Names + D0 = P4_29, + D1 = P4_28, + D2 = P0_4, + D3 = P0_5, + D4 = P2_2, + D5 = P2_3, + D6 = P2_4, + D7 = P2_5, + D8 = P0_0, + D9 = P0_1, + D10 = P0_6, + D11 = P0_9, + D12 = P0_8, + D13 = P0_7, + + A0 = P0_23, + A1 = P0_24, + A2 = P0_25, + A3 = P0_26, + A4 = P1_30, + A5 = P1_31, + // Not connected NC = (int)0xFFFFFFFF } PinName; @@ -89,7 +112,8 @@ typedef enum { PullUp = 0, PullDown = 3, PullNone = 2, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; // version of PINCON_TypeDef using register arrays diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/PinNames.h index c84faffa8d..7ec1b0ab08 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/PinNames.h @@ -163,7 +163,8 @@ typedef enum { PullUp = 0, PullDown = 3, PullNone = 2, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; // version of PINCON_TypeDef using register arrays diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/platform_init.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/platform_init.c index b1963a5991..85940154a7 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/platform_init.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/platform_init.c @@ -8,29 +8,19 @@ void mbed_sdk_init() gpio_t modemEn, modemRst, modemPwrOn, modemLvlOe, modemILvlOe, modemUsbDet; gpio_t gpsEn, gpsRst, led, modemRts; - gpio_init(&modemEn, MDMEN, PIN_OUTPUT); - gpio_init(&modemRst, MDMRST, PIN_OUTPUT); - gpio_init(&modemPwrOn, MDMPWRON, PIN_OUTPUT); - gpio_init(&modemLvlOe, MDMLVLOE, PIN_OUTPUT); - gpio_init(&modemILvlOe, MDMILVLOE, PIN_OUTPUT); - gpio_init(&modemUsbDet, MDMUSBDET, PIN_OUTPUT); - gpio_init(&gpsEn, GPSEN, PIN_OUTPUT); - gpio_init(&gpsRst, GPSRST, PIN_OUTPUT); - gpio_init(&led, LED, PIN_OUTPUT); - gpio_init(&modemRts, MDMRTS, PIN_OUTPUT); - - gpio_write(&led, 0); // LED1: 0=off - gpio_write(&modemRts, 0); // RTS: 0=ready to send - // we start with the gps disabled - gpio_write(&gpsEn, 0); // LDOEN: 1=on,0=off - gpio_write(&gpsRst, 0); // RESET: 0=reset,1=operating - // we start with the modem disabled - gpio_write(&modemLvlOe, 1); // LVLEN: 1=disabled (uart/gpio) - gpio_write(&modemILvlOe, 0); // ILVLEN: 0=disabled (i2c) - gpio_write(&modemUsbDet, 0); // USBDET: 0=disabled - gpio_write(&modemPwrOn, 1); // PWRON: 1=idle, 0=action - gpio_write(&modemEn, 0); // LDOEN: 1=on, 0=off - gpio_write(&modemRst, 0); // RESET: 0=reset, 1=operating + // start with modem disabled + gpio_init_out_ex(&modemEn, MDMEN, 0); + gpio_init_out_ex(&modemRst, MDMRST, 1); + gpio_init_out_ex(&modemPwrOn, MDMPWRON, 1); + gpio_init_out_ex(&modemLvlOe, MDMLVLOE, 1); + gpio_init_out_ex(&modemILvlOe, MDMILVLOE, 0); + gpio_init_out_ex(&modemUsbDet, MDMUSBDET, 0); + gpio_init_out_ex(&modemRts, MDMRTS, 0); + // start with gps disabled + gpio_init_out_ex(&gpsEn, GPSEN, 0); + gpio_init_out_ex(&gpsRst, GPSRST, 1); + // led should be off + gpio_init_out_ex(&led, LED, 0); wait_ms(50); // when USB cable is inserted the interface chip issues // multiple resets to the target CPU We wait here for a short period to diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c index d1eb24e518..a3903a74fa 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/gpio_api.c @@ -21,7 +21,7 @@ uint32_t gpio_set(PinName pin) { return (1 << ((int)pin & 0x1F)); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; obj->pin = pin; @@ -32,12 +32,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &port_reg->FIOCLR; obj->reg_in = &port_reg->FIOPIN; obj->reg_dir = &port_reg->FIODIR; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c index 2a06b61c31..126b1169e7 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c @@ -364,12 +364,10 @@ int serial_readable(serial_t *obj) { } int serial_writable(serial_t *obj) { - int isWritable = 1; if (NC != uart_data[obj->index].sw_cts.pin) - isWritable = gpio_read(&uart_data[obj->index].sw_cts) == 0; - if (isWritable) - isWritable = obj->uart->LSR & 0x40; - return isWritable; + return (gpio_read(&uart_data[obj->index].sw_cts) == 0) && (obj->uart->LSR & 0x40); //If flow control: writable if CTS low + UART done + else + return obj->uart->LSR & 0x20; //No flow control: writable if space in holding register } void serial_clear(serial_t *obj) { @@ -414,7 +412,7 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi pinmap_pinout(txflow, PinMap_UART_CTS); } else { // Can't enable in hardware, use software emulation - gpio_init(&uart_data[index].sw_cts, txflow, PIN_INPUT); + gpio_init_in(&uart_data[index].sw_cts, txflow); } } if (((FlowControlRTS == type) || (FlowControlRTSCTS == type)) && (NC != rxflow)) { @@ -429,8 +427,7 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi uart1->MCR |= UART_MCR_RTSEN_MASK; pinmap_pinout(rxflow, PinMap_UART_RTS); } else { // can't enable in hardware, use software emulation - gpio_init(&uart_data[index].sw_rts, rxflow, PIN_OUTPUT); - gpio_write(&uart_data[index].sw_rts, 0); + gpio_init_out_ex(&uart_data[index].sw_rts, rxflow, 0); // Enable RX interrupt serial_flow_irq_set(obj, 1); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/PinNames.h index 69ab91fe51..2b85b9ca27 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/PinNames.h @@ -84,7 +84,8 @@ typedef enum { PullUp = 0, PullDown = 3, PullNone = 2, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; // version of PINCON_TypeDef using register arrays diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c index da61f537c3..b0c5a383bf 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/gpio_api.c @@ -24,7 +24,7 @@ uint32_t gpio_set(PinName pin) { return (1 << ((int)pin & 0x1F)); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if (pin == NC) return; obj->pin = pin; @@ -36,12 +36,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &port_reg->FIOCLR; obj->reg_in = &port_reg->FIOPIN; obj->reg_dir = &port_reg->FIODIR; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h index cf08642844..b8290d1561 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h @@ -91,7 +91,8 @@ typedef enum { PullUp = 2, PullDown = 1, PullNone = 0, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c index d4381127ae..b855a42aac 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/gpio_api.c @@ -21,7 +21,7 @@ uint32_t gpio_set(PinName pin) { return (1 << ((int)pin & 0x1F)); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if (pin == NC) return; obj->pin = pin; @@ -33,12 +33,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &port_reg->CLR; obj->reg_in = &port_reg->PIN; obj->reg_dir = &port_reg->DIR; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/PinNames.h index bba256707b..1263aa0f28 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/PinNames.h @@ -556,7 +556,8 @@ typedef enum { PullDown = 3, PullNone = 2, Repeater = 1, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c index 29d036930f..54fe0a28ca 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/gpio_api.c @@ -28,7 +28,7 @@ uint32_t gpio_set(PinName pin) { return (1 << ((int)pin & 0x1F)); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if (pin == NC) return; obj->pin = pin; @@ -41,12 +41,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &port_reg->CLR[port]; obj->reg_in = &port_reg->PIN[port]; obj->reg_dir = &port_reg->DIR[port]; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/TARGET_LPC810/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/TARGET_LPC810/PinNames.h index c651b1e56e..7edc5a6a8b 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/TARGET_LPC810/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/TARGET_LPC810/PinNames.h @@ -62,7 +62,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #define STDIO_UART_TX USBTX diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/TARGET_LPC812/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/TARGET_LPC812/PinNames.h index da918741b1..e220a86ea6 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/TARGET_LPC812/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/TARGET_LPC812/PinNames.h @@ -88,7 +88,8 @@ typedef enum { PullDown = 1, PullNone = 0, Repeater = 3, - OpenDrain = 4 + OpenDrain = 4, + PullDefault = PullDown } PinMode; #define STDIO_UART_TX USBTX diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c index 62754bc3b5..631c92b887 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC81X/gpio_api.c @@ -39,7 +39,7 @@ uint32_t gpio_set(PinName pin) { return (1 << ((int)pin & 0x1F)); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; obj->pin = pin; @@ -49,12 +49,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_clr = &LPC_GPIO_PORT->CLR0; obj->reg_in = &LPC_GPIO_PORT->PIN0; obj->reg_dir = &LPC_GPIO_PORT->DIR0; - - gpio_dir(obj, direction); - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/PinNames.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/PinNames.h index 6b3a1ee419..756d94a6ca 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/PinNames.h @@ -50,122 +50,124 @@ extern "C" { // Low nibble = pin number #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF) #define STM_PIN(X) ((uint32_t)(X) & 0xF) - + typedef enum { PIN_INPUT, PIN_OUTPUT } PinDirection; typedef enum { - PA_0 = 0x00, - PA_1 = 0x01, - PA_2 = 0x02, - PA_3 = 0x03, - PA_4 = 0x04, - PA_5 = 0x05, - PA_6 = 0x06, - PA_7 = 0x07, - PA_8 = 0x08, - PA_9 = 0x09, - PA_10 = 0x0A, - PA_11 = 0x0B, - PA_12 = 0x0C, - PA_13 = 0x0D, - PA_14 = 0x0E, - PA_15 = 0x0F, + PA_0 = 0x00, + PA_1 = 0x01, + PA_2 = 0x02, + PA_3 = 0x03, + PA_4 = 0x04, + PA_5 = 0x05, + PA_6 = 0x06, + PA_7 = 0x07, + PA_8 = 0x08, + PA_9 = 0x09, + PA_10 = 0x0A, + PA_11 = 0x0B, + PA_12 = 0x0C, + PA_13 = 0x0D, + PA_14 = 0x0E, + PA_15 = 0x0F, - PB_0 = 0x10, - PB_1 = 0x11, - PB_2 = 0x12, - PB_3 = 0x13, - PB_4 = 0x14, - PB_5 = 0x15, - PB_6 = 0x16, - PB_7 = 0x17, - PB_8 = 0x18, - PB_9 = 0x19, - PB_10 = 0x1A, - PB_11 = 0x1B, - PB_12 = 0x1C, - PB_13 = 0x1D, - PB_14 = 0x1E, - PB_15 = 0x1F, + PB_0 = 0x10, + PB_1 = 0x11, + PB_2 = 0x12, + PB_3 = 0x13, + PB_4 = 0x14, + PB_5 = 0x15, + PB_6 = 0x16, + PB_7 = 0x17, + PB_8 = 0x18, + PB_9 = 0x19, + PB_10 = 0x1A, + PB_11 = 0x1B, + PB_12 = 0x1C, + PB_13 = 0x1D, + PB_14 = 0x1E, + PB_15 = 0x1F, - PC_0 = 0x20, - PC_1 = 0x21, - PC_2 = 0x22, - PC_3 = 0x23, - PC_4 = 0x24, - PC_5 = 0x25, - PC_6 = 0x26, - PC_7 = 0x27, - PC_8 = 0x28, - PC_9 = 0x29, - PC_10 = 0x2A, - PC_11 = 0x2B, - PC_12 = 0x2C, - PC_13 = 0x2D, - PC_14 = 0x2E, - PC_15 = 0x2F, + PC_0 = 0x20, + PC_1 = 0x21, + PC_2 = 0x22, + PC_3 = 0x23, + PC_4 = 0x24, + PC_5 = 0x25, + PC_6 = 0x26, + PC_7 = 0x27, + PC_8 = 0x28, + PC_9 = 0x29, + PC_10 = 0x2A, + PC_11 = 0x2B, + PC_12 = 0x2C, + PC_13 = 0x2D, + PC_14 = 0x2E, + PC_15 = 0x2F, - PD_2 = 0x32, + PD_2 = 0x32, - PF_0 = 0x50, - PF_1 = 0x51, - PF_4 = 0x54, - PF_5 = 0x55, - PF_6 = 0x56, - PF_7 = 0x57, + PF_0 = 0x50, + PF_1 = 0x51, + PF_4 = 0x54, + PF_5 = 0x55, + PF_6 = 0x56, + PF_7 = 0x57, - // Arduino connector namings - A0 = PA_0, - A1 = PA_1, - A2 = PA_4, - A3 = PB_0, - A4 = PC_1, - A5 = PC_0, - D0 = PA_3, - D1 = PA_2, - D2 = PA_10, - D3 = PB_3, - D4 = PB_5, - D5 = PB_4, - D6 = PB_10, - D7 = PA_8, - D8 = PA_9, - D9 = PC_7, - D10 = PB_6, - D11 = PA_7, - D12 = PA_6, - D13 = PA_5, - D14 = PB_9, - D15 = PB_8, - // Generic signals namings - LED1 = PA_5, - LED2 = PA_5, - LED3 = PA_5, - LED4 = PA_5, - USER_BUTTON = PC_13, - SERIAL_TX = PA_2, - SERIAL_RX = PA_3, - I2C_SCL = PB_8, - I2C_SDA = PB_9, - SPI_MOSI = PA_7, - SPI_MISO = PA_6, - SPI_SCK = PA_5, - SPI_CS = PB_6, - PWM_OUT = PB_3, - - // Not connected - NC = (int)0xFFFFFFFF + // Arduino connector namings + A0 = PA_0, + A1 = PA_1, + A2 = PA_4, + A3 = PB_0, + A4 = PC_1, + A5 = PC_0, + D0 = PA_3, + D1 = PA_2, + D2 = PA_10, + D3 = PB_3, + D4 = PB_5, + D5 = PB_4, + D6 = PB_10, + D7 = PA_8, + D8 = PA_9, + D9 = PC_7, + D10 = PB_6, + D11 = PA_7, + D12 = PA_6, + D13 = PA_5, + D14 = PB_9, + D15 = PB_8, + + // Generic signals namings + LED1 = PA_5, + LED2 = PA_5, + LED3 = PA_5, + LED4 = PA_5, + USER_BUTTON = PC_13, + USBTX = PA_2, + USBRX = PA_3, + I2C_SCL = PB_8, + I2C_SDA = PB_9, + SPI_MOSI = PA_7, + SPI_MISO = PA_6, + SPI_SCK = PA_5, + SPI_CS = PB_6, + PWM_OUT = PB_3, + + // Not connected + NC = (int)0xFFFFFFFF } PinName; typedef enum { PullNone = 0, PullUp = 1, PullDown = 2, - OpenDrain = 3 + OpenDrain = 3, + PullDefault = PullNone } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_api.c index d4610ccaa1..443c99f57b 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/gpio_api.c @@ -41,7 +41,7 @@ uint32_t gpio_set(PinName pin) { return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if (pin == NC) return; uint32_t port_index = STM_PORT(pin); @@ -56,14 +56,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; obj->reg_clr = &gpio->BRR; - - // Configure GPIO - if (direction == PIN_OUTPUT) { - pin_function(pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)); - } - else { // PIN_INPUT - pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c index 430da4f011..42cbc4c897 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/spi_api.c @@ -215,13 +215,19 @@ static inline int ssp_writeable(spi_t *obj) { static inline void ssp_write(spi_t *obj, int value) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_writeable(obj)); - SPI_SendData8(spi, (uint8_t)value); + if(obj->bits == SPI_DataSize_8b) // 8 bit mode + SPI_SendData8(spi, (uint8_t)value); + else + SPI_I2S_SendData16(spi, (uint16_t)value); } static inline int ssp_read(spi_t *obj) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_readable(obj)); - return (int)SPI_ReceiveData8(spi); + if(obj->bits == SPI_DataSize_8b) // 8 bit mode + return (int)SPI_ReceiveData8(spi); + else // 16 bit mode + return (int)SPI_I2S_ReceiveData16(spi); } static inline int ssp_busy(spi_t *obj) { @@ -242,13 +248,19 @@ int spi_slave_receive(spi_t *obj) { int spi_slave_read(spi_t *obj) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); - return (int)SPI_ReceiveData8(spi); + if(obj->bits == SPI_DataSize_8b) // 8 bit mode + return (int)SPI_ReceiveData8(spi); + else + return (int)SPI_I2S_ReceiveData16(spi); } void spi_slave_write(spi_t *obj, int value) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); - while (!ssp_writeable(obj)); - SPI_SendData8(spi, (uint8_t)value); + while (!ssp_writeable(obj)); + if(obj->bits == SPI_DataSize_8b) // 8 bit mode + SPI_SendData8(spi, (uint8_t)value); + else + SPI_I2S_SendData16(spi, (uint16_t)value); } int spi_busy(spi_t *obj) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/PinNames.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/PinNames.h index f17de3656c..0a048d021e 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/PinNames.h @@ -46,117 +46,118 @@ extern "C" { // Low nibble = pin number #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF) #define STM_PIN(X) ((uint32_t)(X) & 0xF) - + typedef enum { PIN_INPUT, PIN_OUTPUT } PinDirection; typedef enum { - PA_0 = 0x00, - PA_1 = 0x01, - PA_2 = 0x02, - PA_3 = 0x03, - PA_4 = 0x04, - PA_5 = 0x05, - PA_6 = 0x06, - PA_7 = 0x07, - PA_8 = 0x08, - PA_9 = 0x09, - PA_10 = 0x0A, - PA_11 = 0x0B, - PA_12 = 0x0C, - PA_13 = 0x0D, - PA_14 = 0x0E, - PA_15 = 0x0F, + PA_0 = 0x00, + PA_1 = 0x01, + PA_2 = 0x02, + PA_3 = 0x03, + PA_4 = 0x04, + PA_5 = 0x05, + PA_6 = 0x06, + PA_7 = 0x07, + PA_8 = 0x08, + PA_9 = 0x09, + PA_10 = 0x0A, + PA_11 = 0x0B, + PA_12 = 0x0C, + PA_13 = 0x0D, + PA_14 = 0x0E, + PA_15 = 0x0F, - PB_0 = 0x10, - PB_1 = 0x11, - PB_2 = 0x12, - PB_3 = 0x13, - PB_4 = 0x14, - PB_5 = 0x15, - PB_6 = 0x16, - PB_7 = 0x17, - PB_8 = 0x18, - PB_9 = 0x19, - PB_10 = 0x1A, - PB_11 = 0x1B, - PB_12 = 0x1C, - PB_13 = 0x1D, - PB_14 = 0x1E, - PB_15 = 0x1F, + PB_0 = 0x10, + PB_1 = 0x11, + PB_2 = 0x12, + PB_3 = 0x13, + PB_4 = 0x14, + PB_5 = 0x15, + PB_6 = 0x16, + PB_7 = 0x17, + PB_8 = 0x18, + PB_9 = 0x19, + PB_10 = 0x1A, + PB_11 = 0x1B, + PB_12 = 0x1C, + PB_13 = 0x1D, + PB_14 = 0x1E, + PB_15 = 0x1F, - PC_0 = 0x20, - PC_1 = 0x21, - PC_2 = 0x22, - PC_3 = 0x23, - PC_4 = 0x24, - PC_5 = 0x25, - PC_6 = 0x26, - PC_7 = 0x27, - PC_8 = 0x28, - PC_9 = 0x29, - PC_10 = 0x2A, - PC_11 = 0x2B, - PC_12 = 0x2C, - PC_13 = 0x2D, - PC_14 = 0x2E, - PC_15 = 0x2F, + PC_0 = 0x20, + PC_1 = 0x21, + PC_2 = 0x22, + PC_3 = 0x23, + PC_4 = 0x24, + PC_5 = 0x25, + PC_6 = 0x26, + PC_7 = 0x27, + PC_8 = 0x28, + PC_9 = 0x29, + PC_10 = 0x2A, + PC_11 = 0x2B, + PC_12 = 0x2C, + PC_13 = 0x2D, + PC_14 = 0x2E, + PC_15 = 0x2F, - PD_0 = 0x30, - PD_1 = 0x31, - PD_2 = 0x32, + PD_0 = 0x30, + PD_1 = 0x31, + PD_2 = 0x32, - // Arduino connector namings - A0 = PA_0, - A1 = PA_1, - A2 = PA_4, - A3 = PB_0, - A4 = PC_1, - A5 = PC_0, - D0 = PA_3, - D1 = PA_2, - D2 = PA_10, - D3 = PB_3, - D4 = PB_5, - D5 = PB_4, - D6 = PB_10, - D7 = PA_8, - D8 = PA_9, - D9 = PC_7, - D10 = PB_6, - D11 = PA_7, - D12 = PA_6, - D13 = PA_5, - D14 = PB_9, - D15 = PB_8, + // Arduino connector namings + A0 = PA_0, + A1 = PA_1, + A2 = PA_4, + A3 = PB_0, + A4 = PC_1, + A5 = PC_0, + D0 = PA_3, + D1 = PA_2, + D2 = PA_10, + D3 = PB_3, + D4 = PB_5, + D5 = PB_4, + D6 = PB_10, + D7 = PA_8, + D8 = PA_9, + D9 = PC_7, + D10 = PB_6, + D11 = PA_7, + D12 = PA_6, + D13 = PA_5, + D14 = PB_9, + D15 = PB_8, - // Generic signals namings - LED1 = PA_5, - LED2 = PA_5, - LED3 = PA_5, - LED4 = PA_5, - USER_BUTTON = PC_13, - SERIAL_TX = PA_2, - SERIAL_RX = PA_3, - I2C_SCL = PB_8, - I2C_SDA = PB_9, - SPI_MOSI = PA_7, - SPI_MISO = PA_6, - SPI_SCK = PA_5, - SPI_CS = PB_6, - PWM_OUT = PB_3, - - // Not connected - NC = (int)0xFFFFFFFF + // Generic signals namings + LED1 = PA_5, + LED2 = PA_5, + LED3 = PA_5, + LED4 = PA_5, + USER_BUTTON = PC_13, + USBTX = PA_2, + USBRX = PA_3, + I2C_SCL = PB_8, + I2C_SDA = PB_9, + SPI_MOSI = PA_7, + SPI_MISO = PA_6, + SPI_SCK = PA_5, + SPI_CS = PB_6, + PWM_OUT = PB_3, + + // Not connected + NC = (int)0xFFFFFFFF } PinName; typedef enum { PullNone = 0, PullUp = 1, PullDown = 2, - OpenDrain = 3 + OpenDrain = 3, + PullDefault = PullNone } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_api.c index 4f52a19f2a..a9b81bce62 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/gpio_api.c @@ -41,7 +41,7 @@ uint32_t gpio_set(PinName pin) { return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if (pin == NC) return; uint32_t port_index = STM_PORT(pin); @@ -56,14 +56,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRR; obj->reg_clr = &gpio->BRR; - - // Configure GPIO - if (direction == PIN_OUTPUT) { - pin_function(pin, STM_PIN_DATA(GPIO_Mode_Out_PP, 0)); - } - else { // PIN_INPUT - pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)); - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PeripheralNames.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PeripheralNames.h index f70b98f7b3..ad989d047f 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PeripheralNames.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PeripheralNames.h @@ -43,7 +43,8 @@ typedef enum { typedef enum { UART_1 = (int)USART1_BASE, - UART_2 = (int)USART2_BASE + UART_2 = (int)USART2_BASE, + UART_3 = (int)USART6_BASE } UARTName; #define STDIO_UART_TX PA_2 @@ -52,12 +53,14 @@ typedef enum { typedef enum { SPI_1 = (int)SPI1_BASE, - SPI_2 = (int)SPI2_BASE + SPI_2 = (int)SPI2_BASE, + SPI_3 = (int)SPI3_BASE } SPIName; typedef enum { I2C_1 = (int)I2C1_BASE, - I2C_2 = (int)I2C2_BASE + I2C_2 = (int)I2C2_BASE, + I2C_3 = (int)I2C3_BASE } I2CName; typedef enum { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PinNames.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PinNames.h index d54279376a..ad76bf83e5 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PinNames.h @@ -53,122 +53,123 @@ extern "C" { #define STM_MODE_EVT_RISING (9) #define STM_MODE_EVT_FALLING (10) #define STM_MODE_EVT_RISING_FALLING (11) - + // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H) // Low nibble = pin number #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF) #define STM_PIN(X) ((uint32_t)(X) & 0xF) - + typedef enum { PIN_INPUT, PIN_OUTPUT } PinDirection; typedef enum { - PA_0 = 0x00, - PA_1 = 0x01, - PA_2 = 0x02, - PA_3 = 0x03, - PA_4 = 0x04, - PA_5 = 0x05, - PA_6 = 0x06, - PA_7 = 0x07, - PA_8 = 0x08, - PA_9 = 0x09, - PA_10 = 0x0A, - PA_11 = 0x0B, - PA_12 = 0x0C, - PA_13 = 0x0D, - PA_14 = 0x0E, - PA_15 = 0x0F, + PA_0 = 0x00, + PA_1 = 0x01, + PA_2 = 0x02, + PA_3 = 0x03, + PA_4 = 0x04, + PA_5 = 0x05, + PA_6 = 0x06, + PA_7 = 0x07, + PA_8 = 0x08, + PA_9 = 0x09, + PA_10 = 0x0A, + PA_11 = 0x0B, + PA_12 = 0x0C, + PA_13 = 0x0D, + PA_14 = 0x0E, + PA_15 = 0x0F, - PB_0 = 0x10, - PB_1 = 0x11, - PB_2 = 0x12, - PB_3 = 0x13, - PB_4 = 0x14, - PB_5 = 0x15, - PB_6 = 0x16, - PB_7 = 0x17, - PB_8 = 0x18, - PB_9 = 0x19, - PB_10 = 0x1A, - PB_12 = 0x1C, - PB_13 = 0x1D, - PB_14 = 0x1E, - PB_15 = 0x1F, + PB_0 = 0x10, + PB_1 = 0x11, + PB_2 = 0x12, + PB_3 = 0x13, + PB_4 = 0x14, + PB_5 = 0x15, + PB_6 = 0x16, + PB_7 = 0x17, + PB_8 = 0x18, + PB_9 = 0x19, + PB_10 = 0x1A, + PB_12 = 0x1C, + PB_13 = 0x1D, + PB_14 = 0x1E, + PB_15 = 0x1F, - PC_0 = 0x20, - PC_1 = 0x21, - PC_2 = 0x22, - PC_3 = 0x23, - PC_4 = 0x24, - PC_5 = 0x25, - PC_6 = 0x26, - PC_7 = 0x27, - PC_8 = 0x28, - PC_9 = 0x29, - PC_10 = 0x2A, - PC_11 = 0x2B, - PC_12 = 0x2C, - PC_13 = 0x2D, - PC_14 = 0x2E, - PC_15 = 0x2F, + PC_0 = 0x20, + PC_1 = 0x21, + PC_2 = 0x22, + PC_3 = 0x23, + PC_4 = 0x24, + PC_5 = 0x25, + PC_6 = 0x26, + PC_7 = 0x27, + PC_8 = 0x28, + PC_9 = 0x29, + PC_10 = 0x2A, + PC_11 = 0x2B, + PC_12 = 0x2C, + PC_13 = 0x2D, + PC_14 = 0x2E, + PC_15 = 0x2F, - PD_2 = 0x32, + PD_2 = 0x32, - PH_0 = 0x70, - PH_1 = 0x71, + PH_0 = 0x70, + PH_1 = 0x71, - // Arduino connector namings - A0 = PA_0, - A1 = PA_1, - A2 = PA_4, - A3 = PB_0, - A4 = PC_1, - A5 = PC_0, - D0 = PA_3, - D1 = PA_2, - D2 = PA_10, - D3 = PB_3, - D4 = PB_5, - D5 = PB_4, - D6 = PB_10, - D7 = PA_8, - D8 = PA_9, - D9 = PC_7, - D10 = PB_6, - D11 = PA_7, - D12 = PA_6, - D13 = PA_5, - D14 = PB_9, - D15 = PB_8, + // Arduino connector namings + A0 = PA_0, + A1 = PA_1, + A2 = PA_4, + A3 = PB_0, + A4 = PC_1, + A5 = PC_0, + D0 = PA_3, + D1 = PA_2, + D2 = PA_10, + D3 = PB_3, + D4 = PB_5, + D5 = PB_4, + D6 = PB_10, + D7 = PA_8, + D8 = PA_9, + D9 = PC_7, + D10 = PB_6, + D11 = PA_7, + D12 = PA_6, + D13 = PA_5, + D14 = PB_9, + D15 = PB_8, - // Generic signals namings - LED1 = PA_5, - LED2 = PA_5, - LED3 = PA_5, - LED4 = PA_5, - USER_BUTTON = PC_13, - SERIAL_TX = PA_2, - SERIAL_RX = PA_3, - I2C_SCL = PB_8, - I2C_SDA = PB_9, - SPI_MOSI = PA_7, - SPI_MISO = PA_6, - SPI_SCK = PA_5, - SPI_CS = PB_6, - PWM_OUT = PB_3, - - // Not connected - NC = (int)0xFFFFFFFF + // Generic signals namings + LED1 = PA_5, + LED2 = PA_5, + LED3 = PA_5, + LED4 = PA_5, + USER_BUTTON = PC_13, + USBTX = PA_2, + USBRX = PA_3, + I2C_SCL = PB_8, + I2C_SDA = PB_9, + SPI_MOSI = PA_7, + SPI_MISO = PA_6, + SPI_SCK = PA_5, + SPI_CS = PB_6, + PWM_OUT = PB_3, + + // Not connected + NC = (int)0xFFFFFFFF } PinName; typedef enum { PullNone = 0, PullUp = 1, PullDown = 2, - OpenDrain = 3 + OpenDrain = 3, + PullDefault = PullNone } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_api.c index b1887d0c65..4dd63ed069 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/gpio_api.c @@ -42,7 +42,7 @@ uint32_t gpio_set(PinName pin) { return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if (pin == NC) return; uint32_t port_index = STM_PORT(pin); @@ -57,14 +57,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRRL; obj->reg_clr = &gpio->BSRRH; - - // Configure GPIO - if (direction == PIN_OUTPUT) { - pin_function(pin, STM_PIN_DATA(STM_MODE_OUTPUT_PP, GPIO_NOPULL, 0)); - } - else { // PIN_INPUT - pin_function(pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c index 3cdd6ea96a..e543571552 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c @@ -44,11 +44,15 @@ static const PinMap PinMap_I2C_SDA[] = { {PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_3, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)}, + {PB_4, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, {NC, NC, 0} }; static const PinMap PinMap_I2C_SCL[] = { {PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PA_8, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {NC, NC, 0} }; @@ -69,6 +73,13 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { if (obj->i2c == I2C_1) { __I2C1_CLK_ENABLE(); } + if (obj->i2c == I2C_2) { + __I2C2_CLK_ENABLE(); + } + + if (obj->i2c == I2C_3) { + __I2C3_CLK_ENABLE(); + } // Configure I2C pins pinmap_pinout(sda, PinMap_I2C_SDA); @@ -207,6 +218,14 @@ void i2c_reset(i2c_t *obj) { __I2C1_FORCE_RESET(); __I2C1_RELEASE_RESET(); } + if (obj->i2c == I2C_2) { + __I2C2_FORCE_RESET(); + __I2C2_RELEASE_RESET(); + } + if (obj->i2c == I2C_3) { + __I2C3_FORCE_RESET(); + __I2C3_RELEASE_RESET(); + } } #if DEVICE_I2CSLAVE diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c index 90a3656a76..7a7fee69d3 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c @@ -37,16 +37,18 @@ static const PinMap PinMap_UART_TX[] = { {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PC_6, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NC, 0} }; static const PinMap PinMap_UART_RX[] = { {PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PC_7, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NC, 0} }; -#define UART_NUM (2) +#define UART_NUM (3) static uint32_t serial_irq_ids[UART_NUM] = {0}; @@ -89,6 +91,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { if (obj->uart == UART_2) { __USART2_CLK_ENABLE(); } + if (obj->uart == UART_3) { + __USART6_CLK_ENABLE(); + } // Configure the UART pins pinmap_pinout(tx, PinMap_UART_TX); @@ -107,6 +112,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { // The index is used by irq if (obj->uart == UART_1) obj->index = 0; if (obj->uart == UART_2) obj->index = 1; + if (obj->uart == UART_3) obj->index = 2; // For stdio management if (obj->uart == STDIO_UART) { @@ -180,6 +186,7 @@ static void uart_irq(UARTName name, int id) { // Not part of mbed api static void uart1_irq(void) {uart_irq(UART_1, 0);} static void uart2_irq(void) {uart_irq(UART_2, 1);} +static void uart3_irq(void) {uart_irq(UART_3, 2);} void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) { irq_handler = handler; @@ -202,6 +209,11 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { vector = (uint32_t)&uart2_irq; } + if (obj->uart == UART_3) { + irq_n = USART6_IRQn; + vector = (uint32_t)&uart3_irq; + } + if (enable) { if (irq == RxIrq) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c index 0cd8347753..d606109f20 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c @@ -39,22 +39,42 @@ static const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PC_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_12, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_5 , SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NC, 0} }; static const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PC_2, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_11, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_4 , SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NC, 0} }; static const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_10, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_10, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_3 , SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NC, 0} }; // Only used in Slave mode static const PinMap PinMap_SPI_SSEL[] = { - {PB_6, SPI_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // Generic IO, not real H/W NSS pin + {PA_4, SPI_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_9 , SPI_2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF5_SPI2)}, + {PA_4 , SPI_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF6_SPI3)}, + {PA_15, SPI_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF6_SPI3)}, {NC, NC, 0} }; @@ -102,11 +122,20 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel if (obj->spi == SPI_1) { __SPI1_CLK_ENABLE(); } + if (obj->spi == SPI_2) { + __SPI2_CLK_ENABLE(); + } + if (obj->spi == SPI_3) { + __SPI3_CLK_ENABLE(); + } // Configure the SPI pins pinmap_pinout(mosi, PinMap_SPI_MOSI); pinmap_pinout(miso, PinMap_SPI_MISO); pinmap_pinout(sclk, PinMap_SPI_SCLK); + if (ssel != NC) { // slave mode + pinmap_pinout(ssel, PinMap_SPI_SSEL); + } // Save new values obj->bits = SPI_DATASIZE_8BIT; @@ -114,7 +143,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel obj->cpha = SPI_PHASE_1EDGE; obj->br_presc = SPI_BAUDRATEPRESCALER_256; // 1MHz (with HSI=16MHz and APB2CLKDivider=2) - if (ssel == NC) { // Master + if (ssel == NC) { // SW NSS Master mode obj->mode = SPI_MODE_MASTER; obj->nss = SPI_NSS_SOFT; } @@ -174,8 +203,15 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { void spi_frequency(spi_t *obj, int hz) { // Get SPI clock frequency - uint32_t PCLK = SystemCoreClock >> 1; + // SPI1 runs from PCLK2, which runs at SystemCoreClock / 2. SPI2 and SPI3 + // run from PCLK1, which runs at SystemCoreClock / 4. + uint32_t PCLK = SystemCoreClock; + switch ((int)obj->spi) { + case SPI_1: PCLK = PCLK >> 1; break; + case SPI_2: PCLK = PCLK >> 2; break; + case SPI_3: PCLK = PCLK >> 2; break; + } // Choose the baud rate divisor (between 2 and 256) uint32_t divisor = PCLK / hz; @@ -215,7 +251,9 @@ static inline int ssp_writeable(spi_t *obj) { static inline void ssp_write(spi_t *obj, int value) { SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi); while (!ssp_writeable(obj)); - spi->DR = (uint8_t)value; + if(obj->bits == SPI_DATASIZE_8BIT) + spi->DR = (uint8_t)value; // 8 bit mode + else spi->DR = (uint16_t)value; // 16 bit mode } static inline int ssp_read(spi_t *obj) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/PinNames.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/PinNames.h index 84cde1719e..db623e2b5e 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/PinNames.h @@ -50,118 +50,119 @@ extern "C" { // Low nibble = pin number #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF) #define STM_PIN(X) ((uint32_t)(X) & 0xF) - + typedef enum { PIN_INPUT, PIN_OUTPUT } PinDirection; typedef enum { - PA_0 = 0x00, - PA_1 = 0x01, - PA_2 = 0x02, - PA_3 = 0x03, - PA_4 = 0x04, - PA_5 = 0x05, - PA_6 = 0x06, - PA_7 = 0x07, - PA_8 = 0x08, - PA_9 = 0x09, - PA_10 = 0x0A, - PA_11 = 0x0B, - PA_12 = 0x0C, - PA_13 = 0x0D, - PA_14 = 0x0E, - PA_15 = 0x0F, + PA_0 = 0x00, + PA_1 = 0x01, + PA_2 = 0x02, + PA_3 = 0x03, + PA_4 = 0x04, + PA_5 = 0x05, + PA_6 = 0x06, + PA_7 = 0x07, + PA_8 = 0x08, + PA_9 = 0x09, + PA_10 = 0x0A, + PA_11 = 0x0B, + PA_12 = 0x0C, + PA_13 = 0x0D, + PA_14 = 0x0E, + PA_15 = 0x0F, - PB_0 = 0x10, - PB_1 = 0x11, - PB_2 = 0x12, - PB_3 = 0x13, - PB_4 = 0x14, - PB_5 = 0x15, - PB_6 = 0x16, - PB_7 = 0x17, - PB_8 = 0x18, - PB_9 = 0x19, - PB_10 = 0x1A, - PB_11 = 0x1B, - PB_12 = 0x1C, - PB_13 = 0x1D, - PB_14 = 0x1E, - PB_15 = 0x1F, + PB_0 = 0x10, + PB_1 = 0x11, + PB_2 = 0x12, + PB_3 = 0x13, + PB_4 = 0x14, + PB_5 = 0x15, + PB_6 = 0x16, + PB_7 = 0x17, + PB_8 = 0x18, + PB_9 = 0x19, + PB_10 = 0x1A, + PB_11 = 0x1B, + PB_12 = 0x1C, + PB_13 = 0x1D, + PB_14 = 0x1E, + PB_15 = 0x1F, - PC_0 = 0x20, - PC_1 = 0x21, - PC_2 = 0x22, - PC_3 = 0x23, - PC_4 = 0x24, - PC_5 = 0x25, - PC_6 = 0x26, - PC_7 = 0x27, - PC_8 = 0x28, - PC_9 = 0x29, - PC_10 = 0x2A, - PC_11 = 0x2B, - PC_12 = 0x2C, - PC_13 = 0x2D, - PC_14 = 0x2E, - PC_15 = 0x2F, + PC_0 = 0x20, + PC_1 = 0x21, + PC_2 = 0x22, + PC_3 = 0x23, + PC_4 = 0x24, + PC_5 = 0x25, + PC_6 = 0x26, + PC_7 = 0x27, + PC_8 = 0x28, + PC_9 = 0x29, + PC_10 = 0x2A, + PC_11 = 0x2B, + PC_12 = 0x2C, + PC_13 = 0x2D, + PC_14 = 0x2E, + PC_15 = 0x2F, - PD_2 = 0x32, + PD_2 = 0x32, - PH_0 = 0x70, - PH_1 = 0x71, + PH_0 = 0x70, + PH_1 = 0x71, - // Arduino connector namings - A0 = PA_0, - A1 = PA_1, - A2 = PA_4, - A3 = PB_0, - A4 = PC_1, - A5 = PC_0, - D0 = PA_3, - D1 = PA_2, - D2 = PA_10, - D3 = PB_3, - D4 = PB_5, - D5 = PB_4, - D6 = PB_10, - D7 = PA_8, - D8 = PA_9, - D9 = PC_7, - D10 = PB_6, - D11 = PA_7, - D12 = PA_6, - D13 = PA_5, - D14 = PB_9, - D15 = PB_8, + // Arduino connector namings + A0 = PA_0, + A1 = PA_1, + A2 = PA_4, + A3 = PB_0, + A4 = PC_1, + A5 = PC_0, + D0 = PA_3, + D1 = PA_2, + D2 = PA_10, + D3 = PB_3, + D4 = PB_5, + D5 = PB_4, + D6 = PB_10, + D7 = PA_8, + D8 = PA_9, + D9 = PC_7, + D10 = PB_6, + D11 = PA_7, + D12 = PA_6, + D13 = PA_5, + D14 = PB_9, + D15 = PB_8, - // Generic signals namings - LED1 = PA_5, - LED2 = PA_5, - LED3 = PA_5, - LED4 = PA_5, - USER_BUTTON = PC_13, - SERIAL_TX = PA_2, - SERIAL_RX = PA_3, - I2C_SCL = PB_8, - I2C_SDA = PB_9, - SPI_MOSI = PA_7, - SPI_MISO = PA_6, - SPI_SCK = PA_5, - SPI_CS = PB_6, - PWM_OUT = PB_3, - - // Not connected - NC = (int)0xFFFFFFFF + // Generic signals namings + LED1 = PA_5, + LED2 = PA_5, + LED3 = PA_5, + LED4 = PA_5, + USER_BUTTON = PC_13, + USBTX = PA_2, + USBRX = PA_3, + I2C_SCL = PB_8, + I2C_SDA = PB_9, + SPI_MOSI = PA_7, + SPI_MISO = PA_6, + SPI_SCK = PA_5, + SPI_CS = PB_6, + PWM_OUT = PB_3, + + // Not connected + NC = (int)0xFFFFFFFF } PinName; typedef enum { PullNone = 0, PullUp = 1, PullDown = 2, - OpenDrain = 3 + OpenDrain = 3, + PullDefault = PullNone } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_api.c index 646a4a74c2..2755c96b7e 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/gpio_api.c @@ -41,7 +41,7 @@ uint32_t gpio_set(PinName pin) { return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if (pin == NC) return; uint32_t port_index = STM_PORT(pin); @@ -56,14 +56,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_in = &gpio->IDR; obj->reg_set = &gpio->BSRRL; obj->reg_clr = &gpio->BSRRH; - - // Configure GPIO - if (direction == PIN_OUTPUT) { - pin_function(pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF)); - } - else { // PIN_INPUT - pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/PinNames.h b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/PinNames.h index 94dd107796..f1bb04e923 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/PinNames.h @@ -51,7 +51,8 @@ typedef enum { PullNone = 0, PullUp = 1, PullDown = 2, - OpenDrain = 3 + OpenDrain = 3, + PullDefault = PullDown } PinMode; #ifdef __cplusplus diff --git a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c index 3501942eed..e9cc039333 100644 --- a/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4XX/gpio_api.c @@ -26,7 +26,7 @@ uint32_t gpio_set(PinName pin) { return 1 << ((uint32_t) pin & 0xF); } -void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { +void gpio_init(gpio_t *obj, PinName pin) { if(pin == NC) return; obj->pin = pin; @@ -39,14 +39,6 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { obj->reg_set = &port_reg->BSRRL; obj->reg_clr = &port_reg->BSRRH; obj->reg_in = &port_reg->IDR; - - - gpio_dir(obj, direction); - - switch (direction) { - case PIN_OUTPUT: pin_mode(pin, PullNone); break; - case PIN_INPUT : pin_mode(pin, PullDown); break; - } } void gpio_mode(gpio_t *obj, PinMode mode) { diff --git a/libraries/net/cellular/CellularModem/at/ATCommandsInterface.cpp b/libraries/net/cellular/CellularModem/at/ATCommandsInterface.cpp index 90be0c2e65..9f711630ce 100644 --- a/libraries/net/cellular/CellularModem/at/ATCommandsInterface.cpp +++ b/libraries/net/cellular/CellularModem/at/ATCommandsInterface.cpp @@ -32,7 +32,7 @@ using std::memmove; #include "ATCommandsInterface.h" ATCommandsInterface::ATCommandsInterface(IOStream* pStream) : - m_pStream(pStream), m_open(false), m_env2AT(), m_AT2Env(), m_processingMtx(), + m_pStream(pStream), m_open(false), m_transactionState(IDLE), m_env2AT(), m_AT2Env(), m_processingMtx(), m_processingThread(&ATCommandsInterface::staticCallback, this, (osPriority)AT_THREAD_PRIORITY, 4*192), m_eventsMgmtMtx(), m_eventsProcessingMtx() { @@ -270,6 +270,7 @@ int ATCommandsInterface::executeInternal(const char* command, IATCommandsProcess } while(msgResult != AT_TIMEOUT); WARN("Command returned no message"); + WARN("Command \"%s\" returned no message", command); return NET_TIMEOUT; } DBG("Command returned with message %d", *msg); @@ -285,6 +286,7 @@ int ATCommandsInterface::executeInternal(const char* command, IATCommandsProcess if(ret != OK) { WARN("Command returned AT result %d with code %d", m_transactionResult.result, m_transactionResult.code); + WARN("Command \"%s\" returned AT result %d with code %d", command, m_transactionResult.result, m_transactionResult.code); } DBG("Command returned successfully"); @@ -751,12 +753,13 @@ void ATCommandsInterface::enableEvents() { m_eventsHandlers[i]->onDispatchStart(); //Enable this kind of events - if(m_eventsHandlers[i]->getEventsEnableCommand() != NULL) + const char* cmd = m_eventsHandlers[i]->getEventsEnableCommand(); + if(cmd != NULL) { - int ret = executeInternal(m_eventsHandlers[i]->getEventsEnableCommand(), this, NULL); //Execute enable command + int ret = executeInternal(cmd, this, NULL); //Execute enable command if(ret) { - WARN("Events enabling command failed"); + WARN("Events enabling command \"%s\" failed", cmd); } } } @@ -775,12 +778,13 @@ void ATCommandsInterface::disableEvents() { m_eventsHandlers[i]->onDispatchStart(); //Disable this kind of events - if(m_eventsHandlers[i]->getEventsDisableCommand() != NULL) + const char* cmd = m_eventsHandlers[i]->getEventsDisableCommand(); + if(cmd != NULL) { - int ret = executeInternal(m_eventsHandlers[i]->getEventsDisableCommand(), this, NULL); //Execute disable command + int ret = executeInternal(cmd, this, NULL); //Execute disable command if(ret) { - WARN("Events disabling command failed"); + WARN("Events disabling command \"%s\" failed", cmd); } } } diff --git a/libraries/net/cellular/CellularModem/link/LinkMonitor.cpp b/libraries/net/cellular/CellularModem/link/LinkMonitor.cpp index 3646b1f7aa..612b376921 100644 --- a/libraries/net/cellular/CellularModem/link/LinkMonitor.cpp +++ b/libraries/net/cellular/CellularModem/link/LinkMonitor.cpp @@ -58,6 +58,8 @@ int LinkMonitor::init(bool gsm) /*virtual*/ int LinkMonitor::onNewATResponseLine(ATCommandsInterface* pInst, const char* line) { DBG("Line is %s", line); + char n[32] = ""; + char s[32] = ""; int v; if( sscanf(line, "+CREG: %*d,%d", &v) >= 1 ) //Reg state is valid { @@ -127,6 +129,13 @@ int LinkMonitor::init(bool gsm) m_rssi = -113 + 2*v; } } + else if ( (sscanf(line, "+CNUM: \"%[^\"]\",\"%[^\"]\",%d", n, s, &v) == 3) || + (sscanf(line, "+CNUM: \"\",\"%[^\"]\",%d", s, &v) == 2) ) + { + if (*s && ((v == 145/*number includes + */) || (v == 129/*otherwise*/))) { + strcpy(m_phoneNumber, s); + } + } return OK; } @@ -150,3 +159,17 @@ int LinkMonitor::getState(int* pRssi, REGISTRATION_STATE* pRegistrationState, BE *pBearer = m_bearer; return OK; } + +int LinkMonitor::getPhoneNumber(char* phoneNumber) +{ + *m_phoneNumber = '\0'; + if (m_gsm) { + int ret = m_pIf->execute("AT+CNUM", this, NULL, DEFAULT_TIMEOUT); + if(ret != OK) + { + return NET_PROTOCOL; + } + } + strcpy(phoneNumber, m_phoneNumber); + return OK; +} \ No newline at end of file diff --git a/libraries/net/cellular/CellularModem/link/LinkMonitor.h b/libraries/net/cellular/CellularModem/link/LinkMonitor.h index 527e3581d3..864909d6c5 100644 --- a/libraries/net/cellular/CellularModem/link/LinkMonitor.h +++ b/libraries/net/cellular/CellularModem/link/LinkMonitor.h @@ -73,6 +73,11 @@ public: */ int getState(int* pRssi, REGISTRATION_STATE* pRegistrationState, BEARER* pBearer); + /** Get my phone number + @param phoneNumber pointer to store the current phoneNumber + @return 0 on success, error code on failure + */ + int getPhoneNumber(char* phoneNumber); protected: //IATCommandsProcessor virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line); @@ -85,7 +90,7 @@ private: bool m_gsm; REGISTRATION_STATE m_registrationState; BEARER m_bearer; - + char m_phoneNumber[16]; }; #endif /* LINKMONITOR_H_ */ diff --git a/libraries/net/cellular/UbloxUSBModem/UbloxModem.cpp b/libraries/net/cellular/UbloxUSBModem/UbloxModem.cpp index 4b3939ecfa..a9fec4cbf0 100644 --- a/libraries/net/cellular/UbloxUSBModem/UbloxModem.cpp +++ b/libraries/net/cellular/UbloxUSBModem/UbloxModem.cpp @@ -41,23 +41,24 @@ UbloxModem::UbloxModem(IOStream* atStream, IOStream* pppStream) : m_linkMonitorInit(false), // LinkMonitor subsystem starts un-initialised m_atOpen(false), // ATCommandsInterface starts in a closed state m_onePort(pppStream == NULL), - m_gsm(true) + m_type(UNKNOWN) { } -class AtiProcessor : public IATCommandsProcessor -{ -public: - AtiProcessor() - { +genericAtProcessor::genericAtProcessor() +{ i = 0; str[0] = '\0'; - } - const char* getInfo(void) { return str; } -private: - virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line) - { +} + +const char* genericAtProcessor::getResponse(void) +{ + return str; +} + +int genericAtProcessor::onNewATResponseLine(ATCommandsInterface* pInst, const char* line) +{ int l = strlen(line); if (i + l + 2 > sizeof(str)) return NET_OVERFLOW; @@ -65,15 +66,12 @@ private: strcat(&str[i], line); i += l; return OK; - } - virtual int onNewEntryPrompt(ATCommandsInterface* pInst) - { +} + +int genericAtProcessor::onNewEntryPrompt(ATCommandsInterface* pInst) +{ return OK; - } -protected: - char str[256]; - int i; -}; +} class CREGProcessor : public IATCommandsProcessor { @@ -130,7 +128,7 @@ int UbloxModem::connect(const char* apn, const char* user, const char* password) m_ipInit = true; m_ppp.init(); } - m_ppp.setup(user, password, m_gsm ? DEFAULT_MSISDN_GSM : DEFAULT_MSISDN_CDMA); + m_ppp.setup(user, password, (m_type != LISA_C200) ? DEFAULT_MSISDN_GSM : DEFAULT_MSISDN_CDMA); int ret = init(); if(ret) @@ -231,8 +229,8 @@ int UbloxModem::sendSM(const char* number, const char* message) } ISMSInterface* sms; - if (m_gsm) sms = &m_GsmSms; - else sms = &m_CdmaSms; + if (m_type == LISA_C200) sms = &m_CdmaSms; + else sms = &m_GsmSms; if(!m_smsInit) { ret = sms->init(); @@ -261,8 +259,8 @@ int UbloxModem::getSM(char* number, char* message, size_t maxLength) } ISMSInterface* sms; - if (m_gsm) sms = &m_GsmSms; - else sms = &m_CdmaSms; + if (m_type == LISA_C200) sms = &m_CdmaSms; + else sms = &m_GsmSms; if(!m_smsInit) { ret = sms->init(); @@ -291,8 +289,8 @@ int UbloxModem::getSMCount(size_t* pCount) } ISMSInterface* sms; - if (m_gsm) sms = &m_GsmSms; - else sms = &m_CdmaSms; + if (m_type == LISA_C200) sms = &m_CdmaSms; + else sms = &m_GsmSms; if(!m_smsInit) { ret = sms->init(); @@ -337,25 +335,40 @@ int UbloxModem::init() { return ret; } - + + ATCommandsInterface::ATResult result; - AtiProcessor atiProcessor; - do - { - ret = m_at.execute("ATI", &atiProcessor, &result); + genericAtProcessor atiProcessor; + ret = m_at.execute("ATI", &atiProcessor, &result); + if (OK != ret) + return ret; + const char* info = atiProcessor.getResponse(); + INFO("Modem Identification [%s]", info); + if (strstr(info, "LISA-C200")) { + m_type = LISA_C200; + m_onePort = true; // force use of only one port } - while (ret != OK); - { - const char* info = atiProcessor.getInfo(); - DBG("Modem Identification [%s]", info); - if (strstr(info, "LISA-C200")) - { - m_gsm = false; // it is CDMA modem - m_onePort = true; // force use of only one port - } + else if (strstr(info, "LISA-U200")) { + m_type = LISA_U200; + } + else if (strstr(info, "SARA-G350")) { + m_type = SARA_G350; } - CREGProcessor cregProcessor(m_gsm); + // enable the network indicator + if (m_type == SARA_G350) { + m_at.executeSimple("AT+UGPIOC=16,2", &result); + } + else if (m_type == LISA_U200) { + m_at.executeSimple("AT+UGPIOC=20,2", &result); + } + else if (m_type == LISA_C200) { + // LISA-C200 02S/22S : GPIO1 do not support network status indication + // m_at.executeSimple("AT+UGPIOC=20,2", &result); + } + INFO("Modem Identification [%s]", info); + + CREGProcessor cregProcessor(m_type != LISA_C200); //Wait for network registration do { @@ -438,8 +451,7 @@ int UbloxModem::getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegis if(!m_linkMonitorInit) { - ret = m_linkMonitor.init(); - ret = m_linkMonitor.init(m_gsm); + ret = m_linkMonitor.init(m_type != LISA_C200); if(ret) { return ret; @@ -456,6 +468,33 @@ int UbloxModem::getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegis return OK; } +int UbloxModem::getPhoneNumber(char* phoneNumber) +{ + int ret = init(); + if(ret) + { + return ret; + } + + if(!m_linkMonitorInit) + { + ret = m_linkMonitor.init(m_type != LISA_C200); + if(ret) + { + return ret; + } + m_linkMonitorInit = true; + } + + ret = m_linkMonitor.getPhoneNumber(phoneNumber); + if(ret) + { + return ret; + } + + return OK; +} + #include "USBHost.h" #include "UbloxGSMModemInitializer.h" #include "UbloxCDMAModemInitializer.h" @@ -485,11 +524,12 @@ int UbloxUSBModem::init() if(m_dongle.getDongleType() == WAN_DONGLE_TYPE_UBLOX_LISAU200) { INFO("Using a u-blox LISA-U200 3G/WCDMA Modem"); + m_type = LISA_U200; } else if(m_dongle.getDongleType() == WAN_DONGLE_TYPE_UBLOX_LISAC200) { INFO("Using a u-blox LISA-C200 CDMA Modem"); - m_gsm = false; + m_type = LISA_C200; m_onePort = true; } else @@ -510,9 +550,10 @@ int UbloxUSBModem::cleanup() UbloxSerModem::UbloxSerModem() : UbloxModem(&m_atStream, NULL), - m_Serial(P0_15,P0_16), + m_Serial(P0_15/*MDMTXD*/,P0_16/*MDMRXD*/), m_atStream(m_Serial) { - m_Serial.baud(115200); + m_Serial.baud(115200/*MDMBAUD*/); + m_Serial.set_flow_control(SerialBase::RTSCTS, P0_22/*MDMRTS*/, P0_17/*MDMCTS*/); } diff --git a/libraries/net/cellular/UbloxUSBModem/UbloxModem.h b/libraries/net/cellular/UbloxUSBModem/UbloxModem.h index 153942785c..dc0e1205a4 100644 --- a/libraries/net/cellular/UbloxUSBModem/UbloxModem.h +++ b/libraries/net/cellular/UbloxUSBModem/UbloxModem.h @@ -30,6 +30,19 @@ #include "link/LinkMonitor.h" #include "CellularModem.h" +class genericAtProcessor : public IATCommandsProcessor +{ +public: + genericAtProcessor(); + const char* getResponse(void); +private: + virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line); + virtual int onNewEntryPrompt(ATCommandsInterface* pInst); +protected: + char str[256]; + int i; +}; + /** u-blox WCDMA modem (LISA-U200) */ class UbloxModem: public CellularModem @@ -92,6 +105,8 @@ public: */ int getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegistrationState, LinkMonitor::BEARER* pBearer); + int getPhoneNumber(char* phoneNumber); + /** Get the ATCommandsInterface instance @return Pointer to the ATCommandsInterface instance */ @@ -130,7 +145,7 @@ private: bool m_atOpen; //< Is the interface to the ATCommandsInterface open? true/false protected: bool m_onePort; - bool m_gsm; + enum { LISA_C200, LISA_U200, SARA_G350, UNKNOWN } m_type; }; #include "WANDongle.h" diff --git a/libraries/rtos/rtx/RTX_CM_lib.h b/libraries/rtos/rtx/RTX_CM_lib.h index d6771b8eca..266ca829a1 100644 --- a/libraries/rtos/rtx/RTX_CM_lib.h +++ b/libraries/rtos/rtx/RTX_CM_lib.h @@ -202,25 +202,25 @@ osThreadDef_t os_thread_def_main = {(os_pthread)main, osPriorityNormal, 0, NULL} #ifdef TARGET_LPC1768 #define INITIAL_SP (0x10008000UL) -#elif TARGET_LPC11U24 +#elif defined(TARGET_LPC11U24) #define INITIAL_SP (0x10002000UL) -#elif TARGET_LPC11U35_401 +#elif defined(TARGET_LPC11U35_401) #define INITIAL_SP (0x10002000UL) -#elif TARGET_LPC1114 +#elif defined(TARGET_LPC1114) #define INITIAL_SP (0x10001000UL) -#elif TARGET_LPC812 +#elif defined(TARGET_LPC812) #define INITIAL_SP (0x10001000UL) -#elif TARGET_KL25Z +#elif defined(TARGET_KL25Z) #define INITIAL_SP (0x20003000UL) -#elif TARGET_LPC4088 +#elif defined(TARGET_LPC4088) #define INITIAL_SP (0x10010000UL) -#elif TARGET_LPC1347 +#elif defined(TARGET_LPC1347) #define INITIAL_SP (0x10002000UL) #endif diff --git a/libraries/rtos/rtx/RTX_Conf_CM.c b/libraries/rtos/rtx/RTX_Conf_CM.c index c1117c6c48..cfb6197f5e 100644 --- a/libraries/rtos/rtx/RTX_Conf_CM.c +++ b/libraries/rtos/rtx/RTX_Conf_CM.c @@ -51,7 +51,7 @@ #ifndef OS_TASKCNT # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC1347) # define OS_TASKCNT 14 -# elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || (TARGET_LPC1114) || (TARGET_LPC812) || defined(TARGET_KL25Z) +# elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC1114) || defined(TARGET_LPC812) || defined(TARGET_KL25Z) # define OS_TASKCNT 6 # endif #endif @@ -60,7 +60,7 @@ #ifndef OS_SCHEDULERSTKSIZE # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC1347) # define OS_SCHEDULERSTKSIZE 256 -# elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || (TARGET_LPC1114) || (TARGET_LPC812) || defined(TARGET_KL25Z) +# elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC1114) || defined(TARGET_LPC812) || defined(TARGET_KL25Z) # define OS_SCHEDULERSTKSIZE 128 # endif #endif @@ -107,7 +107,7 @@ # elif defined(TARGET_LPC1347) # define OS_CLOCK 72000000 -# elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || (TARGET_LPC1114) || defined(TARGET_KL25Z) +# elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC1114) || defined(TARGET_KL25Z) # define OS_CLOCK 48000000 # # elif defined(TARGET_LPC812) diff --git a/libraries/tests/mbed/echo/main.cpp b/libraries/tests/mbed/echo/main.cpp index d1e023d781..583e9d884d 100644 --- a/libraries/tests/mbed/echo/main.cpp +++ b/libraries/tests/mbed/echo/main.cpp @@ -1,8 +1,8 @@ #include "mbed.h" -#ifdef TARGET_NUCLEO_F103RB -#define TXPIN SERIAL_TX -#define RXPIN SERIAL_RX +#if defined(TARGET_NUCLEO_F103RB) || defined(TARGET_NUCLEO_L152RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F030R8) +#define TXPIN STDIO_UART_TX +#define RXPIN STDIO_UART_RX #else #define TXPIN USBTX #define RXPIN USBRX @@ -10,13 +10,13 @@ int main() { char buf[256]; - + Serial pc(TXPIN, RXPIN); pc.baud(115200); - + while (1) { pc.gets(buf, 256); - + pc.printf("%s", buf); } } diff --git a/libraries/tests/mbed/env/test_env.cpp b/libraries/tests/mbed/env/test_env.cpp index 1fc3aa1c2d..1c86c03625 100644 --- a/libraries/tests/mbed/env/test_env.cpp +++ b/libraries/tests/mbed/env/test_env.cpp @@ -19,5 +19,9 @@ void notify_completion(bool success) { } printf("{{end}}" NL); - led_blink(success?LED1:LED4); +#ifdef LED4 + led_blink(success ? LED1 : LED4); +#else + led_blink(success ? LED1 : NC); +#endif } diff --git a/libraries/tests/mbed/interruptin/main.cpp b/libraries/tests/mbed/interruptin/main.cpp index c4562ae988..4a8e336f9f 100644 --- a/libraries/tests/mbed/interruptin/main.cpp +++ b/libraries/tests/mbed/interruptin/main.cpp @@ -29,6 +29,10 @@ void in_handler() { #define PIN_IN (p11) #define PIN_OUT (p12) +#elif defined(TARGET_NUCLEO_F103RB) || defined(TARGET_NUCLEO_L152RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F030R8) +#define PIN_IN (PB_8) +#define PIN_OUT (PC_6) + #else #define PIN_IN (p5) #define PIN_OUT (p25) diff --git a/libraries/tests/mbed/ticker_2/main.cpp b/libraries/tests/mbed/ticker_2/main.cpp index 6d7e569673..24f3e7546a 100644 --- a/libraries/tests/mbed/ticker_2/main.cpp +++ b/libraries/tests/mbed/ticker_2/main.cpp @@ -5,13 +5,13 @@ DigitalOut led(LED1); #ifdef TARGET_KL25Z DigitalOut out(PTA1); -#elif TARGET_LPC812 +#elif defined(TARGET_LPC812) DigitalOut out(D10); -#elif TARGET_KL05Z +#elif defined(TARGET_KL05Z) DigitalOut out(PTB1); -#elif TARGET_KL46Z +#elif defined(TARGET_KL46Z) DigitalOut out(PTA1); diff --git a/libraries/tests/mbed/time_us/main.cpp b/libraries/tests/mbed/time_us/main.cpp index 549ae26d9d..4a6038139b 100644 --- a/libraries/tests/mbed/time_us/main.cpp +++ b/libraries/tests/mbed/time_us/main.cpp @@ -3,13 +3,13 @@ #ifdef TARGET_KL25Z DigitalOut out(PTD4); -#elif TARGET_KL05Z +#elif defined(TARGET_KL05Z) DigitalOut out(PTB1); -#elif TARGET_KL46Z +#elif defined(TARGET_KL46Z) DigitalOut out(PTA1); -#elif TARGET_LPC812 +#elif defined(TARGET_LPC812) DigitalOut out(D10); #else diff --git a/libraries/tests/mbed/timeout/main.cpp b/libraries/tests/mbed/timeout/main.cpp index a496f0c502..ab9f99614e 100644 --- a/libraries/tests/mbed/timeout/main.cpp +++ b/libraries/tests/mbed/timeout/main.cpp @@ -5,10 +5,10 @@ DigitalOut led(LED1); #ifdef TARGET_KL25Z DigitalOut out(PTA1); -#elif TARGET_KL05Z +#elif defined(TARGET_KL05Z) DigitalOut out(PTB1); -#elif TARGET_KL46Z +#elif defined(TARGET_KL46Z) DigitalOut out(PTA1); #elif defined(TARGET_LPC812) diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingData.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingData.cpp new file mode 100644 index 0000000000..d52c9ea7c8 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingData.cpp @@ -0,0 +1,240 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + +#include +#include + +#include "GapAdvertisingData.h" + +/**************************************************************************/ +/*! + \brief Creates a new GapAdvertisingData instance + + \par EXAMPLE + + \code + + \endcode +*/ +/**************************************************************************/ +GapAdvertisingData::GapAdvertisingData(void) +{ + memset(_payload, 0, GAP_ADVERTISING_DATA_MAX_PAYLOAD); + _payloadLen = 0; + _appearance = GENERIC_TAG; +} + +/**************************************************************************/ +/*! + Destructor +*/ +/**************************************************************************/ +GapAdvertisingData::~GapAdvertisingData(void) +{ +} + +/**************************************************************************/ +/*! + \brief Adds advertising data based on the specified AD type (see + DataType) + + \args[in] advDataType The Advertising 'DataType' to add + \args[in] payload Pointer to the payload contents + \args[in] len Size of the payload in bytes + + \returns ble_error_t + + \retval BLE_ERROR_NONE + Everything executed properly + + \retval BLE_ERROR_BUFFER_OVERFLOW + The specified data would cause the advertising buffer + to overflow + + \par EXAMPLE + + \code + + \endcode +*/ +/**************************************************************************/ +ble_error_t GapAdvertisingData::addData(DataType advDataType, uint8_t * payload, uint8_t len) +{ + /* ToDo: Check if an AD type already exists and if the existing */ + /* value is exclusive or not (flags, etc.) */ + + /* Make sure we don't exceed the 31 byte payload limit */ + if (_payloadLen + len + 2 >= GAP_ADVERTISING_DATA_MAX_PAYLOAD) + return BLE_ERROR_BUFFER_OVERFLOW; + + /* Field length */ + memset(&_payload[_payloadLen], len+1, 1); + _payloadLen++; + + /* Field ID */ + memset(&_payload[_payloadLen], (uint8_t)advDataType, 1); + _payloadLen++; + + /* Payload */ + memcpy(&_payload[_payloadLen], payload, len); + _payloadLen += len; + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + \brief Helper function to add APPEARANCE data to the advertising + payload + + \args[in] appearance The APPEARANCE value to add + + \returns ble_error_t + + \retval BLE_ERROR_NONE + Everything executed properly + + \retval BLE_ERROR_BUFFER_OVERFLOW + The specified data would cause the advertising buffer + to overflow + + \par EXAMPLE + + \code + + \endcode +*/ +/**************************************************************************/ +ble_error_t GapAdvertisingData::addAppearance(Appearance appearance) +{ + _appearance = appearance; + return addData(GapAdvertisingData::APPEARANCE, (uint8_t*)&appearance, 2); +} + +/**************************************************************************/ +/*! + \brief Helper function to add FLAGS data to the advertising + payload + + \args[in] flag The FLAGS value to add + + \par LE_LIMITED_DISCOVERABLE + The peripheral is discoverable for a limited period of + time + + \par LE_GENERAL_DISCOVERABLE + The peripheral is permanently discoverable + + \par BREDR_NOT_SUPPORTED + This peripheral is a Bluetooth Low Energy only device + (no EDR support) + + \returns ble_error_t + + \retval BLE_ERROR_NONE + Everything executed properly + + \retval BLE_ERROR_BUFFER_OVERFLOW + The specified data would cause the advertising buffer + to overflow + + \par EXAMPLE + + \code + + \endcode +*/ +/**************************************************************************/ +ble_error_t GapAdvertisingData::addFlags(Flags flag) +{ + return addData(GapAdvertisingData::FLAGS, (uint8_t*)&flag, 1); +} + +/**************************************************************************/ +/*! + \brief Helper function to add TX_POWER_LEVEL data to the + advertising payload + + \args[in] flag The TX_POWER_LEVEL value to add + + \returns ble_error_t + + \retval BLE_ERROR_NONE + Everything executed properly + + \retval BLE_ERROR_BUFFER_OVERFLOW + The specified data would cause the advertising buffer + to overflow + + \par EXAMPLE + + \code + + \endcode +*/ +/**************************************************************************/ +ble_error_t GapAdvertisingData::addTxPower(int8_t txPower) +{ + /* ToDo: Basic error checking to make sure txPower is in range */ + return addData(GapAdvertisingData::TX_POWER_LEVEL, (uint8_t*)&txPower, 1); +} + +/**************************************************************************/ +/*! + \brief Clears the payload and resets the payload length counter +*/ +/**************************************************************************/ +void GapAdvertisingData::clear(void) +{ + memset(&_payload, 0, GAP_ADVERTISING_DATA_MAX_PAYLOAD); + _payloadLen = 0; +} + +/**************************************************************************/ +/*! + \brief Returns a pointer to the the current payload + + \returns A pointer to the payload +*/ +/**************************************************************************/ +uint8_t * GapAdvertisingData::getPayload(void) +{ + return (_payloadLen > 0) ? _payload : NULL; +} + +/**************************************************************************/ +/*! + \brief Returns the current payload length (0..31 bytes) + + \returns The payload length in bytes +*/ +/**************************************************************************/ +uint8_t GapAdvertisingData::getPayloadLen(void) +{ + return _payloadLen; +} + +/**************************************************************************/ +/*! + \brief Returns the 16-bit appearance value for this device + + \returns The 16-bit appearance value +*/ +/**************************************************************************/ +uint16_t GapAdvertisingData::getAppearance(void) +{ + return (uint16_t)_appearance; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingData.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingData.h new file mode 100644 index 0000000000..89b60dd208 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingData.h @@ -0,0 +1,212 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __GAP_ADVERTISING_DATA_H__ +#define __GAP_ADVERTISING_DATA_H__ + +#include "blecommon.h" + +#define GAP_ADVERTISING_DATA_MAX_PAYLOAD (31) + +/**************************************************************************/ +/*! + \brief + This class provides several helper functions to generate properly + formatted GAP Advertising and Scan Response data payloads + + \note + See Bluetooth Specification 4.0 (Vol. 3), Part C, Section 11 and 18 + for further information on Advertising and Scan Response data. + + \par Advertising and Scan Response Payloads + Advertising data and Scan Response data are organized around a set of + data types called 'AD types' in Bluetooth 4.0 (see the Bluetooth Core + Specification v4.0, Vol. 3, Part C, Sections 11 and 18). + + \par + Each AD type has it's own standardized 'assigned number', as defined + by the Bluetooth SIG: + https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile + + \par + For convenience sake, all appropriate AD types have been encapsulated + into GapAdvertisingData::DataType. + + \par + Before the AD Types and their payload (if any) can be inserted into + the Advertising or Scan Response frames, they need to be formatted as + follows: + + \li \c Record length (1 byte) + \li \c AD Type (1 byte) + \li \c AD payload (optional, only present if record length > 1) + + \par + This class takes care of properly formatting the payload, performs + some basic checks on the payload length, and tries to avoid common + errors like adding an exclusive AD field twice in the Advertising + or Scan Response payload. + + \par EXAMPLE + + \code + + // ToDo + + \endcode +*/ +/**************************************************************************/ +class GapAdvertisingData +{ + public: + /**********************************************************************/ + /*! + \brief + A list of Advertising Data types commonly used by peripherals. + These AD types are used to describe the capabilities of the + peripheral, and get inserted inside the advertising or scan + response payloads. + + \par Source + \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 11, 18 + \li \c https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile + */ + /**********************************************************************/ + enum DataType + { + FLAGS = 0x01, /**< \ref Flags */ + INCOMPLETE_LIST_16BIT_SERVICE_IDS = 0x02, /**< Incomplete list of 16-bit Service IDs */ + COMPLETE_LIST_16BIT_SERVICE_IDS = 0x03, /**< Complete list of 16-bit Service IDs */ + INCOMPLETE_LIST_32BIT_SERVICE_IDS = 0x04, /**< Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */ + COMPLETE_LIST_32BIT_SERVICE_IDS = 0x05, /**< Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */ + INCOMPLETE_LIST_128BIT_SERVICE_IDS = 0x06, /**< Incomplete list of 128-bit Service IDs */ + COMPLETE_LIST_128BIT_SERVICE_IDS = 0x07, /**< Complete list of 128-bit Service IDs */ + SHORTENED_LOCAL_NAME = 0x08, /**< Shortened Local Name */ + COMPLETE_LOCAL_NAME = 0x09, /**< Complete Local Name */ + TX_POWER_LEVEL = 0x0A, /**< TX Power Level (in dBm) */ + DEVICE_ID = 0x10, /**< Device ID */ + SLAVE_CONNECTION_INTERVAL_RANGE = 0x12, /**< Slave Connection Interval Range */ + SERVICE_DATA = 0x16, /**< Service Data */ + APPEARANCE = 0x19, /**< \ref Appearance */ + ADVERTISING_INTERVAL = 0x1A, /**< Advertising Interval */ + MANUFACTURER_SPECIFIC_DATA = 0xFF /**< Manufacturer Specific Data */ + }; + + /**********************************************************************/ + /*! + \brief + A list of values for the FLAGS AD Type + + \note + You can use more than one value in the FLAGS AD Type (ex. + LE_GENERAL_DISCOVERABLE and BREDR_NOT_SUPPORTED). + + \par Source + \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 18.1 + */ + /**********************************************************************/ + enum Flags + { + LE_LIMITED_DISCOVERABLE = 0x01, /**< Peripheral device is discoverable for a limited period of time */ + LE_GENERAL_DISCOVERABLE = 0x02, /**< Peripheral device is discoverable at any moment */ + BREDR_NOT_SUPPORTED = 0x04, /**< Peripheral device is LE only */ + SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not relevant - central mode only */ + SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not relevant - central mode only */ + }; + + /**********************************************************************/ + /*! + \brief + A list of values for the APPEARANCE AD Type, which describes the + physical shape or appearance of the device + + \par Source + \li \c Bluetooth Core Specification Supplement, Part A, Section 1.12 + \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 12.2 + \li \c https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml + */ + /**********************************************************************/ + enum Appearance + { + UNKNOWN = 0, /**< Unknown of unspecified appearance type */ + GENERIC_PHONE = 64, /**< Generic Phone */ + GENERIC_COMPUTER = 128, /**< Generic Computer */ + GENERIC_WATCH = 192, /**< Generic Watch */ + WATCH_SPORTS_WATCH = 193, /**< Sports Watch */ + GENERIC_CLOCK = 256, /**< Generic Clock */ + GENERIC_DISPLAY = 320, /**< Generic Display */ + GENERIC_REMOTE_CONTROL = 384, /**< Generic Remote Control */ + GENERIC_EYE_GLASSES = 448, /**< Generic Eye Glasses */ + GENERIC_TAG = 512, /**< Generic Tag */ + GENERIC_KEYRING = 576, /**< Generic Keyring */ + GENERIC_MEDIA_PLAYER = 640, /**< Generic Media Player */ + GENERIC_BARCODE_SCANNER = 704, /**< Generic Barcode Scanner */ + GENERIC_THERMOMETER = 768, /**< Generic Thermometer */ + THERMOMETER_EAR = 769, /**< Ear Thermometer */ + GENERIC_HEART_RATE_SENSOR = 832, /**< Generic Heart Rate Sensor */ + HEART_RATE_SENSOR_HEART_RATE_BELT = 833, /**< Belt Heart Rate Sensor */ + GENERIC_BLOOD_PRESSURE = 896, /**< Generic Blood Pressure */ + BLOOD_PRESSURE_ARM = 897, /**< Arm Blood Pressure */ + BLOOD_PRESSURE_WRIST = 898, /**< Wrist Blood Pressure */ + HUMAN_INTERFACE_DEVICE_HID = 960, /**< Human Interface Device (HID) */ + KEYBOARD = 961, /**< Keyboard */ + MOUSE = 962, /**< Mouse */ + JOYSTICK = 963, /**< Joystick */ + GAMEPAD = 964, /**< Gamepad */ + DIGITIZER_TABLET = 965, /**< Digitizer Tablet */ + CARD_READER = 966, /**< Card Read */ + DIGITAL_PEN = 967, /**< Digital Pen */ + BARCODE_SCANNER = 968, /**< Barcode Scanner */ + GENERIC_GLUCOSE_METER = 1024, /**< Generic Glucose Meter */ + GENERIC_RUNNING_WALKING_SENSOR = 1088, /**< Generic Running/Walking Sensor */ + RUNNING_WALKING_SENSOR_IN_SHOE = 1089, /**< In Shoe Running/Walking Sensor */ + RUNNING_WALKING_SENSOR_ON_SHOE = 1090, /**< On Shoe Running/Walking Sensor */ + RUNNING_WALKING_SENSOR_ON_HIP = 1091, /**< On Hip Running/Walking Sensor */ + GENERIC_CYCLING = 1152, /**< Generic Cycling */ + CYCLING_CYCLING_COMPUTER = 1153, /**< Cycling Computer */ + CYCLING_SPEED_SENSOR = 1154, /**< Cycling Speed Senspr */ + CYCLING_CADENCE_SENSOR = 1155, /**< Cycling Cadence Sensor */ + CYCLING_POWER_SENSOR = 1156, /**< Cycling Power Sensor */ + CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, /**< Cycling Speed and Cadence Sensor */ + PULSE_OXIMETER_GENERIC = 3136, /**< Generic Pulse Oximeter */ + PULSE_OXIMETER_FINGERTIP = 3137, /**< Fingertip Pulse Oximeter */ + PULSE_OXIMETER_WRIST_WORN = 3138, /**< Wrist Worn Pulse Oximeter */ + OUTDOOR_GENERIC = 5184, /**< Generic Outdoor */ + OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185, /**< Outdoor Location Display Device */ + OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186, /**< Outdoor Location and Navigation Display Device */ + OUTDOOR_LOCATION_POD = 5187, /**< Outdoor Location Pod */ + OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188 /**< Outdoor Location and Navigation Pod */ + }; + + GapAdvertisingData(void); + virtual ~GapAdvertisingData(void); + + ble_error_t addData(DataType, uint8_t *, uint8_t); + ble_error_t addAppearance(Appearance appearance = GENERIC_TAG); + ble_error_t addFlags(Flags flag = LE_GENERAL_DISCOVERABLE); + ble_error_t addTxPower(int8_t txPower); + void clear(void); + uint8_t * getPayload(void); + uint8_t getPayloadLen(void); + uint16_t getAppearance(void); + + private: + uint8_t _payload[GAP_ADVERTISING_DATA_MAX_PAYLOAD]; + uint8_t _payloadLen; + uint16_t _appearance; +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingParams.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingParams.cpp new file mode 100644 index 0000000000..348e52d46d --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingParams.cpp @@ -0,0 +1,168 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + +#include +#include + +#include "blecommon.h" +#include "GapAdvertisingParams.h" + +/**************************************************************************/ +/*! + \brief + Instantiates a new GapAdvertisingParams instance + + \param[in] advType + The GAP advertising mode to use for this device. Valid + values are defined in AdvertisingType: + + \par ADV_NON_CONNECTABLE_UNDIRECTED + All connections to the peripheral device will be refused. + + \par ADV_CONNECTABLE_DIRECTED + Only connections from a pre-defined central device will be + accepted. + + \par ADV_CONNECTABLE_UNDIRECTED + Any central device can connect to this peripheral. + + \par ADV_SCANNABLE_UNDIRECTED + Any central device can connect to this peripheral, and + the secondary Scan Response payload will be included or + available to central devices. + + \par + See Bluetooth Core Specification 4.0 (Vol. 3), Part C, + Section 9.3 and Core Specification 4.0 (Vol. 6), Part B, + Section 2.3.1 for further information on GAP connection + modes + + \param[in] interval + Advertising interval between 0x0020 and 0x4000 in 0.625ms + units (20ms to 10.24s). If using non-connectable mode + (ADV_NON_CONNECTABLE_UNDIRECTED) this min value is + 0x00A0 (100ms). + + \par + Increasing this value will allow central devices to detect + your peripheral faster at the expense of more power being + used by the radio due to the higher data transmit rate. + + \par + This field must be set to 0 if connectionMode is equal + to ADV_CONNECTABLE_DIRECTED + + \par + See Bluetooth Core Specification, Vol 3., Part C, + Appendix A for suggested advertising intervals. + + \param[in] timeout + Advertising timeout between 0x1 and 0x3FFF (1 and 16383) + in seconds. Enter 0 to disable the advertising timeout. + + \par EXAMPLE + + \code + + \endcode +*/ +/**************************************************************************/ +GapAdvertisingParams::GapAdvertisingParams(AdvertisingType advType, uint16_t interval, uint16_t timeout) +{ + _advType = advType; + _interval = interval; + _timeout = timeout; + + /* Interval checks */ + if (_advType == ADV_CONNECTABLE_DIRECTED) + { + /* Interval must be 0 in directed connectable mode */ + _interval = 0; + } + else if (_advType == ADV_NON_CONNECTABLE_UNDIRECTED) + { + /* Min interval is slightly larger than in other modes */ + if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) + { + _interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON; + } + if (_interval > GAP_ADV_PARAMS_INTERVAL_MAX) + { + _interval = GAP_ADV_PARAMS_INTERVAL_MAX; + } + } + else + { + /* Stay within interval limits */ + if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN) + { + _interval = GAP_ADV_PARAMS_INTERVAL_MIN; + } + if (_interval > GAP_ADV_PARAMS_INTERVAL_MAX) + { + _interval = GAP_ADV_PARAMS_INTERVAL_MAX; + } + } + + /* Timeout checks */ + if (timeout) + { + /* Stay within timeout limits */ + if (_timeout > GAP_ADV_PARAMS_TIMEOUT_MAX) + { + _timeout = GAP_ADV_PARAMS_TIMEOUT_MAX; + } + } +} + +/**************************************************************************/ +/*! + Destructor +*/ +/**************************************************************************/ +GapAdvertisingParams::~GapAdvertisingParams(void) +{ +} + +/**************************************************************************/ +/*! + \brief returns the current Advertising Type value +*/ +/**************************************************************************/ +GapAdvertisingParams::AdvertisingType GapAdvertisingParams::getAdvertisingType(void) +{ + return _advType; +} + +/**************************************************************************/ +/*! + \brief returns the current Advertising Delay (in units of 0.625ms) +*/ +/**************************************************************************/ +uint16_t GapAdvertisingParams::getInterval(void) +{ + return _interval; +} + +/**************************************************************************/ +/*! + \brief returns the current Advertising Timeout (in seconds) +*/ +/**************************************************************************/ +uint16_t GapAdvertisingParams::getTimeout(void) +{ + return _timeout; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingParams.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingParams.h new file mode 100644 index 0000000000..639980165e --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GapAdvertisingParams.h @@ -0,0 +1,89 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __GAP_ADVERTISING_PARAMS_H__ +#define __GAP_ADVERTISING_PARAMS_H__ + +#include "blecommon.h" + +#define GAP_ADV_PARAMS_INTERVAL_MIN (0x0020) +#define GAP_ADV_PARAMS_INTERVAL_MIN_NONCON (0x00A0) +#define GAP_ADV_PARAMS_INTERVAL_MAX (0x1000) +#define GAP_ADV_PARAMS_TIMEOUT_MAX (0x3FFF) + +/**************************************************************************/ +/*! + \brief + This class provides a wrapper for the core advertising parameters, + including the advertising type (Connectable Undirected, + Non Connectable Undirected, etc.), as well as the advertising and + timeout intervals. + + \par + See the following for more information on advertising types: + + \li \c Bluetooth Core Specification 4.0 (Vol. 6), Part B, Section 2.3.1 + \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 9.3 + + \par EXAMPLE + + \code + + // ToDo + + \endcode +*/ +/**************************************************************************/ +class GapAdvertisingParams +{ + public: + /**************************************************************************/ + /*! + \brief + Encapsulates the peripheral advertising modes, which determine how + the device appears to other central devices in hearing range + + \par + See the following for more information on advertising types: + + \li \c Bluetooth Core Specification 4.0 (Vol. 6), Part B, Section 2.3.1 + \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 9.3 + */ + /**************************************************************************/ + enum AdvertisingType + { + ADV_CONNECTABLE_UNDIRECTED, /**< Vol 3, Part C, Section 9.3.4 and Vol 6, Part B, Section 2.3.1.1 */ + ADV_CONNECTABLE_DIRECTED, /**< Vol 3, Part C, Section 9.3.3 and Vol 6, Part B, Section 2.3.1.2 */ + ADV_SCANNABLE_UNDIRECTED, /**< Include support for Scan Response payloads, see Vol 6, Part B, Section 2.3.1.4 */ + ADV_NON_CONNECTABLE_UNDIRECTED /**< Vol 3, Part C, Section 9.3.2 and Vol 6, Part B, Section 2.3.1.3 */ + }; + + GapAdvertisingParams(AdvertisingType advType = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED, + uint16_t interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON, + uint16_t timeout = 0); + virtual ~GapAdvertisingParams(void); + + virtual AdvertisingType getAdvertisingType(void); + virtual uint16_t getInterval(void); + virtual uint16_t getTimeout(void); + + private: + AdvertisingType _advType; + uint16_t _interval; + uint16_t _timeout; +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattCharacteristic.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattCharacteristic.cpp new file mode 100644 index 0000000000..46a20cd50f --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattCharacteristic.cpp @@ -0,0 +1,65 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + +#include +#include + +#include "GattCharacteristic.h" + +/**************************************************************************/ +/*! + @brief Creates a new GattCharacteristic using the specified 16-bit + UUID, value length, and properties + + @note The UUID value must be unique in the service and is normally >1 + + @param[in] id + The 16-bit UUID to use for this characteristic + @param[in] minLen + The min length in bytes of this characteristic's value + @param[in] maxLen + The max length in bytes of this characteristic's value + @param[in] props + The 8-bit bit field containing the characteristic's + properties + + @section EXAMPLE + + @code + + // UUID = 0x2A19, Min length 2, Max len = 2, Properties = write + GattCharacteristic c = GattCharacteristic( 0x2A19, 2, 2, BLE_GATT_CHAR_PROPERTIES_WRITE ); + + @endcode +*/ +/**************************************************************************/ +GattCharacteristic::GattCharacteristic(uint16_t id, uint16_t minLen, uint16_t maxLen, uint8_t props) +{ + uuid = id; + memcpy(&properties, &props, 1); + lenMin = minLen; + lenMax = maxLen; +// handle = 0; +} + +/**************************************************************************/ +/*! + Destructor +*/ +/**************************************************************************/ +GattCharacteristic::~GattCharacteristic(void) +{ +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattCharacteristic.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattCharacteristic.h new file mode 100644 index 0000000000..c3be061bd5 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattCharacteristic.h @@ -0,0 +1,318 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __GATT_CHARACTERISTIC_H__ +#define __GATT_CHARACTERISTIC_H__ + +#include "blecommon.h" +#include "UUID.h" + +#include "ble_gatts.h" +/* ToDo: Update to use 16-bit or 128-bit UUIDs! */ + +/**************************************************************************/ +/*! + \brief GATT characteristic +*/ +/**************************************************************************/ +class GattCharacteristic +{ + public: + enum + { + UUID_BATTERY_LEVEL_STATE_CHAR = 0x2A1B, + UUID_BATTERY_POWER_STATE_CHAR = 0x2A1A, + UUID_REMOVABLE_CHAR = 0x2A3A, + UUID_SERVICE_REQUIRED_CHAR = 0x2A3B, + UUID_ALERT_CATEGORY_ID_CHAR = 0x2A43, + UUID_ALERT_CATEGORY_ID_BIT_MASK_CHAR = 0x2A42, + UUID_ALERT_LEVEL_CHAR = 0x2A06, + UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR = 0x2A44, + UUID_ALERT_STATUS_CHAR = 0x2A3F, + UUID_BATTERY_LEVEL_CHAR = 0x2A19, + UUID_BLOOD_PRESSURE_FEATURE_CHAR = 0x2A49, + UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR = 0x2A35, + UUID_BODY_SENSOR_LOCATION_CHAR = 0x2A38, + UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR = 0x2A22, + UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR = 0x2A32, + UUID_BOOT_MOUSE_INPUT_REPORT_CHAR = 0x2A33, + UUID_CURRENT_TIME_CHAR = 0x2A2B, + UUID_DATE_TIME_CHAR = 0x2A08, + UUID_DAY_DATE_TIME_CHAR = 0x2A0A, + UUID_DAY_OF_WEEK_CHAR = 0x2A09, + UUID_DST_OFFSET_CHAR = 0x2A0D, + UUID_EXACT_TIME_256_CHAR = 0x2A0C, + UUID_FIRMWARE_REVISION_STRING_CHAR = 0x2A26, + UUID_GLUCOSE_FEATURE_CHAR = 0x2A51, + UUID_GLUCOSE_MEASUREMENT_CHAR = 0x2A18, + UUID_GLUCOSE_MEASUREMENT_CONTEXT_CHAR = 0x2A34, + UUID_HARDWARE_REVISION_STRING_CHAR = 0x2A27, + UUID_HEART_RATE_CONTROL_POINT_CHAR = 0x2A39, + UUID_HEART_RATE_MEASUREMENT_CHAR = 0x2A37, + UUID_HID_CONTROL_POINT_CHAR = 0x2A4C, + UUID_HID_INFORMATION_CHAR = 0x2A4A, + UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR = 0x2A2A, + UUID_INTERMEDIATE_CUFF_PRESSURE_CHAR = 0x2A36, + UUID_INTERMEDIATE_TEMPERATURE_CHAR = 0x2A1E, + UUID_LOCAL_TIME_INFORMATION_CHAR = 0x2A0F, + UUID_MANUFACTURER_NAME_STRING_CHAR = 0x2A29, + UUID_MEASUREMENT_INTERVAL_CHAR = 0x2A21, + UUID_MODEL_NUMBER_STRING_CHAR = 0x2A24, + UUID_UNREAD_ALERT_CHAR = 0x2A45, + UUID_NEW_ALERT_CHAR = 0x2A46, + UUID_PNP_ID_CHAR = 0x2A50, + UUID_PROTOCOL_MODE_CHAR = 0x2A4E, + UUID_RECORD_ACCESS_CONTROL_POINT_CHAR = 0x2A52, + UUID_REFERENCE_TIME_INFORMATION_CHAR = 0x2A14, + UUID_REPORT_CHAR = 0x2A4D, + UUID_REPORT_MAP_CHAR = 0x2A4B, + UUID_RINGER_CONTROL_POINT_CHAR = 0x2A40, + UUID_RINGER_SETTING_CHAR = 0x2A41, + UUID_SCAN_INTERVAL_WINDOW_CHAR = 0x2A4F, + UUID_SCAN_REFRESH_CHAR = 0x2A31, + UUID_SERIAL_NUMBER_STRING_CHAR = 0x2A25, + UUID_SOFTWARE_REVISION_STRING_CHAR = 0x2A28, + UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR = 0x2A47, + UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR = 0x2A48, + UUID_SYSTEM_ID_CHAR = 0x2A23, + UUID_TEMPERATURE_MEASUREMENT_CHAR = 0x2A1C, + UUID_TEMPERATURE_TYPE_CHAR = 0x2A1D, + UUID_TIME_ACCURACY_CHAR = 0x2A12, + UUID_TIME_SOURCE_CHAR = 0x2A13, + UUID_TIME_UPDATE_CONTROL_POINT_CHAR = 0x2A16, + UUID_TIME_UPDATE_STATE_CHAR = 0x2A17, + UUID_TIME_WITH_DST_CHAR = 0x2A11, + UUID_TIME_ZONE_CHAR = 0x2A0E, + UUID_TX_POWER_LEVEL_CHAR = 0x2A07, + UUID_CSC_FEATURE_CHAR = 0x2A5C, + UUID_CSC_MEASUREMENT_CHAR = 0x2A5B, + UUID_RSC_FEATURE_CHAR = 0x2A54, + UUID_RSC_MEASUREMENT_CHAR = 0x2A53, + }; + + /**************************************************************************/ + /*! + \brief Standard GATT characteristic presentation format unit types. + These unit types are used to decribe what the raw numeric + data in a characteristic actually represents. + + \note See https://developer.bluetooth.org/gatt/units/Pages/default.aspx + */ + /**************************************************************************/ + typedef enum ble_gatt_unit_e + { + BLE_GATT_UNIT_NONE = 0x2700, /**< No specified unit type */ + BLE_GATT_UNIT_LENGTH_METRE = 0x2701, /**< Length, Metre */ + BLE_GATT_UNIT_MASS_KILOGRAM = 0x2702, /**< Mass, Kilogram */ + BLE_GATT_UNIT_TIME_SECOND = 0x2703, /**< Time, Second */ + BLE_GATT_UNIT_ELECTRIC_CURRENT_AMPERE = 0x2704, /**< Electric Current, Ampere */ + BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_KELVIN = 0x2705, /**< Thermodynamic Temperature, Kelvin */ + BLE_GATT_UNIT_AMOUNT_OF_SUBSTANCE_MOLE = 0x2706, /**< Amount of Substance, Mole */ + BLE_GATT_UNIT_LUMINOUS_INTENSITY_CANDELA = 0x2707, /**< Luminous Intensity, Candela */ + BLE_GATT_UNIT_AREA_SQUARE_METRES = 0x2710, /**< Area, Square Metres */ + BLE_GATT_UNIT_VOLUME_CUBIC_METRES = 0x2711, /**< Volume, Cubic Metres*/ + BLE_GATT_UNIT_VELOCITY_METRES_PER_SECOND = 0x2712, /**< Velocity, Metres per Second*/ + BLE_GATT_UNIT_ACCELERATION_METRES_PER_SECOND_SQUARED = 0x2713, /**< Acceleration, Metres per Second Squared */ + BLE_GATT_UNIT_WAVENUMBER_RECIPROCAL_METRE = 0x2714, /**< Wave Number Reciprocal, Metre */ + BLE_GATT_UNIT_DENSITY_KILOGRAM_PER_CUBIC_METRE = 0x2715, /**< Density, Kilogram per Cubic Metre */ + BLE_GATT_UNIT_SURFACE_DENSITY_KILOGRAM_PER_SQUARE_METRE = 0x2716, /**< */ + BLE_GATT_UNIT_SPECIFIC_VOLUME_CUBIC_METRE_PER_KILOGRAM = 0x2717, /**< */ + BLE_GATT_UNIT_CURRENT_DENSITY_AMPERE_PER_SQUARE_METRE = 0x2718, /**< */ + BLE_GATT_UNIT_MAGNETIC_FIELD_STRENGTH_AMPERE_PER_METRE = 0x2719, /**< Magnetic Field Strength, Ampere per Metre */ + BLE_GATT_UNIT_AMOUNT_CONCENTRATION_MOLE_PER_CUBIC_METRE = 0x271A, /**< */ + BLE_GATT_UNIT_MASS_CONCENTRATION_KILOGRAM_PER_CUBIC_METRE = 0x271B, /**< */ + BLE_GATT_UNIT_LUMINANCE_CANDELA_PER_SQUARE_METRE = 0x271C, /**< */ + BLE_GATT_UNIT_REFRACTIVE_INDEX = 0x271D, /**< */ + BLE_GATT_UNIT_RELATIVE_PERMEABILITY = 0x271E, /**< */ + BLE_GATT_UNIT_PLANE_ANGLE_RADIAN = 0x2720, /**< */ + BLE_GATT_UNIT_SOLID_ANGLE_STERADIAN = 0x2721, /**< */ + BLE_GATT_UNIT_FREQUENCY_HERTZ = 0x2722, /**< Frequency, Hertz */ + BLE_GATT_UNIT_FORCE_NEWTON = 0x2723, /**< Force, Newton */ + BLE_GATT_UNIT_PRESSURE_PASCAL = 0x2724, /**< Pressure, Pascal */ + BLE_GATT_UNIT_ENERGY_JOULE = 0x2725, /**< Energy, Joule */ + BLE_GATT_UNIT_POWER_WATT = 0x2726, /**< Power, Watt */ + BLE_GATT_UNIT_ELECTRIC_CHARGE_COULOMB = 0x2727, /**< Electrical Charge, Coulomb */ + BLE_GATT_UNIT_ELECTRIC_POTENTIAL_DIFFERENCE_VOLT = 0x2728, /**< Electrical Potential Difference, Voltage */ + BLE_GATT_UNIT_CAPACITANCE_FARAD = 0x2729, /**< */ + BLE_GATT_UNIT_ELECTRIC_RESISTANCE_OHM = 0x272A, /**< */ + BLE_GATT_UNIT_ELECTRIC_CONDUCTANCE_SIEMENS = 0x272B, /**< */ + BLE_GATT_UNIT_MAGNETIC_FLEX_WEBER = 0x272C, /**< */ + BLE_GATT_UNIT_MAGNETIC_FLEX_DENSITY_TESLA = 0x272D, /**< */ + BLE_GATT_UNIT_INDUCTANCE_HENRY = 0x272E, /**< */ + BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_CELSIUS = 0x272F, /**< */ + BLE_GATT_UNIT_LUMINOUS_FLUX_LUMEN = 0x2730, /**< */ + BLE_GATT_UNIT_ILLUMINANCE_LUX = 0x2731, /**< */ + BLE_GATT_UNIT_ACTIVITY_REFERRED_TO_A_RADIONUCLIDE_BECQUEREL = 0x2732, /**< */ + BLE_GATT_UNIT_ABSORBED_DOSE_GRAY = 0x2733, /**< */ + BLE_GATT_UNIT_DOSE_EQUIVALENT_SIEVERT = 0x2734, /**< */ + BLE_GATT_UNIT_CATALYTIC_ACTIVITY_KATAL = 0x2735, /**< */ + BLE_GATT_UNIT_DYNAMIC_VISCOSITY_PASCAL_SECOND = 0x2740, /**< */ + BLE_GATT_UNIT_MOMENT_OF_FORCE_NEWTON_METRE = 0x2741, /**< */ + BLE_GATT_UNIT_SURFACE_TENSION_NEWTON_PER_METRE = 0x2742, /**< */ + BLE_GATT_UNIT_ANGULAR_VELOCITY_RADIAN_PER_SECOND = 0x2743, /**< */ + BLE_GATT_UNIT_ANGULAR_ACCELERATION_RADIAN_PER_SECOND_SQUARED = 0x2744, /**< */ + BLE_GATT_UNIT_HEAT_FLUX_DENSITY_WATT_PER_SQUARE_METRE = 0x2745, /**< */ + BLE_GATT_UNIT_HEAT_CAPACITY_JOULE_PER_KELVIN = 0x2746, /**< */ + BLE_GATT_UNIT_SPECIFIC_HEAT_CAPACITY_JOULE_PER_KILOGRAM_KELVIN = 0x2747, /**< */ + BLE_GATT_UNIT_SPECIFIC_ENERGY_JOULE_PER_KILOGRAM = 0x2748, /**< */ + BLE_GATT_UNIT_THERMAL_CONDUCTIVITY_WATT_PER_METRE_KELVIN = 0x2749, /**< */ + BLE_GATT_UNIT_ENERGY_DENSITY_JOULE_PER_CUBIC_METRE = 0x274A, /**< */ + BLE_GATT_UNIT_ELECTRIC_FIELD_STRENGTH_VOLT_PER_METRE = 0x274B, /**< */ + BLE_GATT_UNIT_ELECTRIC_CHARGE_DENSITY_COULOMB_PER_CUBIC_METRE = 0x274C, /**< */ + BLE_GATT_UNIT_SURFACE_CHARGE_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274D, /**< */ + BLE_GATT_UNIT_ELECTRIC_FLUX_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274E, /**< */ + BLE_GATT_UNIT_PERMITTIVITY_FARAD_PER_METRE = 0x274F, /**< */ + BLE_GATT_UNIT_PERMEABILITY_HENRY_PER_METRE = 0x2750, /**< */ + BLE_GATT_UNIT_MOLAR_ENERGY_JOULE_PER_MOLE = 0x2751, /**< */ + BLE_GATT_UNIT_MOLAR_ENTROPY_JOULE_PER_MOLE_KELVIN = 0x2752, /**< */ + BLE_GATT_UNIT_EXPOSURE_COULOMB_PER_KILOGRAM = 0x2753, /**< */ + BLE_GATT_UNIT_ABSORBED_DOSE_RATE_GRAY_PER_SECOND = 0x2754, /**< */ + BLE_GATT_UNIT_RADIANT_INTENSITY_WATT_PER_STERADIAN = 0x2755, /**< */ + BLE_GATT_UNIT_RADIANCE_WATT_PER_SQUARE_METRE_STERADIAN = 0x2756, /**< */ + BLE_GATT_UNIT_CATALYTIC_ACTIVITY_CONCENTRATION_KATAL_PER_CUBIC_METRE = 0x2757, /**< */ + BLE_GATT_UNIT_TIME_MINUTE = 0x2760, /**< Time, Minute */ + BLE_GATT_UNIT_TIME_HOUR = 0x2761, /**< Time, Hour */ + BLE_GATT_UNIT_TIME_DAY = 0x2762, /**< Time, Day */ + BLE_GATT_UNIT_PLANE_ANGLE_DEGREE = 0x2763, /**< */ + BLE_GATT_UNIT_PLANE_ANGLE_MINUTE = 0x2764, /**< */ + BLE_GATT_UNIT_PLANE_ANGLE_SECOND = 0x2765, /**< */ + BLE_GATT_UNIT_AREA_HECTARE = 0x2766, /**< */ + BLE_GATT_UNIT_VOLUME_LITRE = 0x2767, /**< */ + BLE_GATT_UNIT_MASS_TONNE = 0x2768, /**< */ + BLE_GATT_UNIT_PRESSURE_BAR = 0x2780, /**< Pressure, Bar */ + BLE_GATT_UNIT_PRESSURE_MILLIMETRE_OF_MERCURY = 0x2781, /**< Pressure, Millimetre of Mercury */ + BLE_GATT_UNIT_LENGTH_ANGSTROM = 0x2782, /**< */ + BLE_GATT_UNIT_LENGTH_NAUTICAL_MILE = 0x2783, /**< */ + BLE_GATT_UNIT_AREA_BARN = 0x2784, /**< */ + BLE_GATT_UNIT_VELOCITY_KNOT = 0x2785, /**< */ + BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_NEPER = 0x2786, /**< */ + BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_BEL = 0x2787, /**< */ + BLE_GATT_UNIT_LENGTH_YARD = 0x27A0, /**< Length, Yard */ + BLE_GATT_UNIT_LENGTH_PARSEC = 0x27A1, /**< Length, Parsec */ + BLE_GATT_UNIT_LENGTH_INCH = 0x27A2, /**< Length, Inch */ + BLE_GATT_UNIT_LENGTH_FOOT = 0x27A3, /**< Length, Foot */ + BLE_GATT_UNIT_LENGTH_MILE = 0x27A4, /**< Length, Mile */ + BLE_GATT_UNIT_PRESSURE_POUND_FORCE_PER_SQUARE_INCH = 0x27A5, /**< */ + BLE_GATT_UNIT_VELOCITY_KILOMETRE_PER_HOUR = 0x27A6, /**< Velocity, Kilometre per Hour */ + BLE_GATT_UNIT_VELOCITY_MILE_PER_HOUR = 0x27A7, /**< Velocity, Mile per Hour */ + BLE_GATT_UNIT_ANGULAR_VELOCITY_REVOLUTION_PER_MINUTE = 0x27A8, /**< Angular Velocity, Revolution per Minute */ + BLE_GATT_UNIT_ENERGY_GRAM_CALORIE = 0x27A9, /**< Energy, Gram Calorie */ + BLE_GATT_UNIT_ENERGY_KILOGRAM_CALORIE = 0x27AA, /**< Energy, Kilogram Calorie */ + BLE_GATT_UNIT_ENERGY_KILOWATT_HOUR = 0x27AB, /**< Energy, Killowatt Hour */ + BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_FAHRENHEIT = 0x27AC, /**< */ + BLE_GATT_UNIT_PERCENTAGE = 0x27AD, /**< Percentage */ + BLE_GATT_UNIT_PER_MILLE = 0x27AE, /**< */ + BLE_GATT_UNIT_PERIOD_BEATS_PER_MINUTE = 0x27AF, /**< */ + BLE_GATT_UNIT_ELECTRIC_CHARGE_AMPERE_HOURS = 0x27B0, /**< */ + BLE_GATT_UNIT_MASS_DENSITY_MILLIGRAM_PER_DECILITRE = 0x27B1, /**< */ + BLE_GATT_UNIT_MASS_DENSITY_MILLIMOLE_PER_LITRE = 0x27B2, /**< */ + BLE_GATT_UNIT_TIME_YEAR = 0x27B3, /**< Time, Year */ + BLE_GATT_UNIT_TIME_MONTH = 0x27B4, /**< Time, Month */ + BLE_GATT_UNIT_CONCENTRATION_COUNT_PER_CUBIC_METRE = 0x27B5, /**< */ + BLE_GATT_UNIT_IRRADIANCE_WATT_PER_SQUARE_METRE = 0x27B6 /**< */ + } ble_gatt_unit_t; + + /**************************************************************************/ + /*! + \brief Standard GATT number types + + \note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.2 + \note See http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml + */ + /**************************************************************************/ + typedef enum ble_gatt_format_e + { + BLE_GATT_FORMAT_RFU = 0x00, /**< Reserved For Future Use. */ + BLE_GATT_FORMAT_BOOLEAN = 0x01, /**< Boolean. */ + BLE_GATT_FORMAT_2BIT = 0x02, /**< Unsigned 2-bit integer. */ + BLE_GATT_FORMAT_NIBBLE = 0x03, /**< Unsigned 4-bit integer. */ + BLE_GATT_FORMAT_UINT8 = 0x04, /**< Unsigned 8-bit integer. */ + BLE_GATT_FORMAT_UINT12 = 0x05, /**< Unsigned 12-bit integer. */ + BLE_GATT_FORMAT_UINT16 = 0x06, /**< Unsigned 16-bit integer. */ + BLE_GATT_FORMAT_UINT24 = 0x07, /**< Unsigned 24-bit integer. */ + BLE_GATT_FORMAT_UINT32 = 0x08, /**< Unsigned 32-bit integer. */ + BLE_GATT_FORMAT_UINT48 = 0x09, /**< Unsigned 48-bit integer. */ + BLE_GATT_FORMAT_UINT64 = 0x0A, /**< Unsigned 64-bit integer. */ + BLE_GATT_FORMAT_UINT128 = 0x0B, /**< Unsigned 128-bit integer. */ + BLE_GATT_FORMAT_SINT8 = 0x0C, /**< Signed 2-bit integer. */ + BLE_GATT_FORMAT_SINT12 = 0x0D, /**< Signed 12-bit integer. */ + BLE_GATT_FORMAT_SINT16 = 0x0E, /**< Signed 16-bit integer. */ + BLE_GATT_FORMAT_SINT24 = 0x0F, /**< Signed 24-bit integer. */ + BLE_GATT_FORMAT_SINT32 = 0x10, /**< Signed 32-bit integer. */ + BLE_GATT_FORMAT_SINT48 = 0x11, /**< Signed 48-bit integer. */ + BLE_GATT_FORMAT_SINT64 = 0x12, /**< Signed 64-bit integer. */ + BLE_GATT_FORMAT_SINT128 = 0x13, /**< Signed 128-bit integer. */ + BLE_GATT_FORMAT_FLOAT32 = 0x14, /**< IEEE-754 32-bit floating point. */ + BLE_GATT_FORMAT_FLOAT64 = 0x15, /**< IEEE-754 64-bit floating point. */ + BLE_GATT_FORMAT_SFLOAT = 0x16, /**< IEEE-11073 16-bit SFLOAT. */ + BLE_GATT_FORMAT_FLOAT = 0x17, /**< IEEE-11073 32-bit FLOAT. */ + BLE_GATT_FORMAT_DUINT16 = 0x18, /**< IEEE-20601 format. */ + BLE_GATT_FORMAT_UTF8S = 0x19, /**< UTF-8 string. */ + BLE_GATT_FORMAT_UTF16S = 0x1A, /**< UTF-16 string. */ + BLE_GATT_FORMAT_STRUCT = 0x1B /**< Opaque Structure. */ + } ble_gatt_format_t; + + /**************************************************************************/ + /*! + \brief Standard GATT characteritic properties + + \note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.1.1 + and Section 3.3.3.1 for Extended Properties + */ + /**************************************************************************/ + typedef enum ble_gatt_char_properties_e + { + BLE_GATT_CHAR_PROPERTIES_BROADCAST = 0x01, /**< Permits broadcasts of the Characteristic Value using Server Characteristic Configuration Descriptor. */ + BLE_GATT_CHAR_PROPERTIES_READ = 0x02, /**< Permits reads of the Characteristic Value. */ + BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE = 0x04, /**< Permits writes of the Characteristic Value without response. */ + BLE_GATT_CHAR_PROPERTIES_WRITE = 0x08, /**< Permits writes of the Characteristic Value with response. */ + BLE_GATT_CHAR_PROPERTIES_NOTIFY = 0x10, /**< Permits notifications of a Characteristic Value without acknowledgement. */ + BLE_GATT_CHAR_PROPERTIES_INDICATE = 0x20, /**< Permits indications of a Characteristic Value with acknowledgement. */ + BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES = 0x40, /**< Permits signed writes to the Characteristic Value. */ + BLE_GATT_CHAR_PROPERTIES_EXTENDED_PROPERTIES = 0x80 /**< Additional characteristic properties are defined in the Characteristic Extended Properties Descriptor */ + } ble_gatt_char_properties_t; + + /**************************************************************************/ + /*! + \brief GATT presentation format wrapper + + \note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5 + \note See https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml + */ + /**************************************************************************/ + typedef struct PresentationFormat + { + uint8_t gatt_format; /**< Format of the value, see @ref ble_gatt_format_t. */ + int8_t exponent; /**< Exponent for integer data types. Ex. if Exponent = -3 and the char value is 3892, the actual value is 3.892 */ + uint16_t gatt_unit; /**< UUID from Bluetooth Assigned Numbers, see @ref ble_gatt_unit_t. */ + uint8_t gatt_namespace; /**< Namespace from Bluetooth Assigned Numbers, normally '1', see @ref BLE_GATT_CPF_NAMESPACES. */ + uint16_t gatt_nsdesc; /**< Namespace description from Bluetooth Assigned Numbers, normally '0', see @ref BLE_GATT_CPF_NAMESPACES. */ + } presentation_format_t; + + GattCharacteristic(uint16_t uuid=0, uint16_t minLen=1, uint16_t maxLen=1, uint8_t properties=0); + virtual ~GattCharacteristic(void); + + uint16_t uuid; /* Characteristic UUID */ + uint16_t lenMin; /* Minimum length of the value */ + uint16_t lenMax; /* Maximum length of the value */ + uint16_t handle; + uint8_t properties; + + private: +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattService.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattService.cpp new file mode 100644 index 0000000000..7c7795bbf9 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattService.cpp @@ -0,0 +1,111 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + + +#include +#include + +#include "GattService.h" + +/**************************************************************************/ +/*! + @brief Creates a new GattService using the specified 128-bit UUID + + @note The UUID value must be unique on the device + + @param[in] uuid + The 16 byte (128-bit) UUID to use for this characteristic + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +GattService::GattService(uint8_t base_uuid[16]) +{ + primaryServiceID.update(base_uuid); + characteristicCount = 0; + handle = 0; +} + +/**************************************************************************/ +/*! + @brief Creates a new GattService using the specified 16-bit BLE UUID + + @param[in] ble_uuid + The standardised 16-bit (2 byte) BLE UUID to use for this + characteristic + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +GattService::GattService(uint16_t ble_uuid) +{ + primaryServiceID.update( ble_uuid ); + characteristicCount = 0; + handle = 0; +} + +/**************************************************************************/ +/*! + @brief Destructor +*/ +/**************************************************************************/ +GattService::~GattService(void) +{ +} + +/**************************************************************************/ +/*! + @brief Adds a GattCharacterisic to the service. + + @note This function will not update the .handle field in the + GattCharacteristic. This value is updated when the parent + service is added via the radio driver. + + @param[in] characteristic + The GattCharacteristic object describing the characteristic + to add to this service + + @returns BLE_ERROR_NONE (0) if everything executed correctly, or an + error code if there was a problem + @retval BLE_ERROR_NONE + Everything executed correctly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t GattService::addCharacteristic(GattCharacteristic & characteristic) +{ + /* ToDo: Make sure we don't overflow the array, etc. */ + /* ToDo: Make sure this characteristic UUID doesn't already exist */ + /* ToDo: Basic validation */ + + characteristics[characteristicCount] = &characteristic; + characteristicCount++; + + return BLE_ERROR_NONE; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattService.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattService.h new file mode 100644 index 0000000000..4350117a1a --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/GattService.h @@ -0,0 +1,70 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __GATT_SERVICE_H__ +#define __GATT_SERVICE_H__ + +#include "blecommon.h" +#include "UUID.h" +#include "GattCharacteristic.h" + +#define BLE_SERVICE_MAX_CHARACTERISTICS (5) + +/**************************************************************************/ +/*! + \brief GATT service +*/ +/**************************************************************************/ +class GattService +{ + private: + + public: + GattService(uint8_t[16]); /* 128-bit Base UUID */ + GattService(uint16_t); /* 16-bit BLE UUID */ + virtual ~GattService(void); + + UUID primaryServiceID; + uint8_t characteristicCount; + GattCharacteristic* characteristics[BLE_SERVICE_MAX_CHARACTERISTICS]; + uint16_t handle; + + ble_error_t addCharacteristic(GattCharacteristic &); + + enum { + UUID_ALERT_NOTIFICATION_SERVICE = 0x1811, + UUID_BATTERY_SERVICE = 0x180F, + UUID_BLOOD_PRESSURE_SERVICE = 0x1810, + UUID_CURRENT_TIME_SERVICE = 0x1805, + UUID_CYCLING_SPEED_AND_CADENCE = 0x1816, + UUID_DEVICE_INFORMATION_SERVICE = 0x180A, + UUID_GLUCOSE_SERVICE = 0x1808, + UUID_HEALTH_THERMOMETER_SERVICE = 0x1809, + UUID_HEART_RATE_SERVICE = 0x180D, + UUID_HUMAN_INTERFACE_DEVICE_SERVICE = 0x1812, + UUID_IMMEDIATE_ALERT_SERVICE = 0x1802, + UUID_LINK_LOSS_SERVICE = 0x1803, + UUID_NEXT_DST_CHANGE_SERVICE = 0x1807, + UUID_PHONE_ALERT_STATUS_SERVICE = 0x180E, + UUID_REFERENCE_TIME_UPDATE_SERVICE = 0x1806, + UUID_RUNNING_SPEED_AND_CADENCE = 0x1814, + UUID_SCAN_PARAMETERS_SERVICE = 0x1813, + UUID_TX_POWER_SERVICE = 0x1804 + }; +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/UUID.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/UUID.cpp new file mode 100644 index 0000000000..4a4fb35a64 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/UUID.cpp @@ -0,0 +1,194 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + + +#include +#include + +#include "UUID.h" + +/**************************************************************************/ +/*! + @brief Creates an empty 128-bit UUID + + @note This UUID must be assigned a valid value via the 'update' + function before it can be safely used! +*/ +/**************************************************************************/ +UUID::UUID(void) +{ + memset(base, 0, 16); + value = 0; + type = UUID_TYPE_SHORT; +} + +/**************************************************************************/ +/*! + @brief Creates a new 128-bit UUID + + @note The UUID is a unique 128-bit (16 byte) ID used to identify + different service or characteristics on the BLE device. + + @note When creating a UUID, the constructor will check if all bytes + except bytes 2/3 are equal to 0. If only bytes 2/3 have a + value, the UUID will be treated as a short/BLE UUID, and the + .type field will be set to UUID::UUID_TYPE_SHORT. If any + of the bytes outside byte 2/3 have a non-zero value, the UUID + will be considered a 128-bit ID, and .type will be assigned + as UUID::UUID_TYPE_LONG. + + @param[in] uuid_base + The 128-bit (16-byte) UUID value. For 128-bit values, + assign all 16 bytes. For 16-bit values, assign the + 16-bits to byte 2 and 3, and leave the rest of the bytes + as 0. + + @section EXAMPLE + + @code + + // Create a short UUID (0x180F) + uint8_t shortID[16] = { 0, 0, 0x0F, 0x18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + UUID ble_uuid = UUID(shortID); + // ble_uuid.type = UUID_TYPE_SHORT + // ble_uuid.value = 0x180F + + // Creeate a long UUID + uint8_t longID[16] = { 0x00, 0x11, 0x22, 0x33, + 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, + 0xCC, 0xDD, 0xEE, 0xFF }; + UUID custom_uuid = UUID(longID); + // custom_uuid.type = UUID_TYPE_LONG + // custom_uuid.value = 0x3322 + // custom_uuid.base = 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF + + @endcode +*/ +/**************************************************************************/ +UUID::UUID(uint8_t const uuid_base[16]) +{ + memcpy(base, uuid_base, 16); + value = (uint16_t)((uuid_base[3] << 8) | (uuid_base[2])); + + /* Check if this is a short of a long UUID */ + if (uuid_base[0] + uuid_base[1] + + uuid_base[4] + uuid_base[5] + uuid_base[6] + uuid_base[7] + + uuid_base[8] + uuid_base[9] + uuid_base[10] + uuid_base[11] + + uuid_base[12] + uuid_base[13] + uuid_base[14] + uuid_base[15] == 0) + { + type = UUID_TYPE_SHORT; + } + else + { + type = UUID_TYPE_LONG; + } +} + +/**************************************************************************/ +/*! + @brief Creates a short (16-bit) UUID + + @param[in] ble_uuid + The 16-bit BLE UUID value. +*/ +/**************************************************************************/ +UUID::UUID(uint16_t const ble_uuid) +{ + memset(base, 0, 16); + memcpy(base+2, (uint8_t *)&ble_uuid, 2); + value = ble_uuid; + type = UUID_TYPE_SHORT; +} + +/**************************************************************************/ +/*! + @brief UUID destructor +*/ +/**************************************************************************/ +UUID::~UUID(void) +{ +} + +/**************************************************************************/ +/*! + @brief Updates the value of the UUID + + @args[in] uuid_base + The 128-bit value to use when updating the UUID. For + 16-bit IDs, insert the ID in bytes 2/3 in LSB format. + + @returns BLE_ERROR_NONE (0) if everything executed correctly, or an + error code if there was a problem + @retval BLE_ERROR_NONE + Everything executed correctly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t UUID::update(uint8_t const uuid_base[16]) +{ + memcpy(base, uuid_base, 16); + value = (uint16_t)((uuid_base[3] << 8) | (uuid_base[2])); + + /* Check if this is a short of a long UUID */ + if (uuid_base[0] + uuid_base[1] + + uuid_base[4] + uuid_base[5] + uuid_base[6] + uuid_base[7] + + uuid_base[8] + uuid_base[9] + uuid_base[10] + uuid_base[11] + + uuid_base[12] + uuid_base[13] + uuid_base[14] + uuid_base[15] == 0) + { + type = UUID_TYPE_SHORT; + } + else + { + type = UUID_TYPE_LONG; + } + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Updates the value of the UUID + + @args[in] ble_uuid + The 16-bit value to use when updating the UUID. + + @returns BLE_ERROR_NONE (0) if everything executed correctly, or an + error code if there was a problem + @retval BLE_ERROR_NONE + Everything executed correctly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t UUID::update(uint16_t const ble_uuid) +{ + memset(base, 0, 16); + memcpy(base+2, (uint8_t *)&ble_uuid, 2); + value = ble_uuid; + type = UUID_TYPE_SHORT; + + return BLE_ERROR_NONE; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/UUID.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/UUID.h new file mode 100644 index 0000000000..70019235a1 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/UUID.h @@ -0,0 +1,47 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __UUID_H__ +#define __UUID_H__ + +#include "blecommon.h" + +class UUID +{ +private: + +public: + enum + { + UUID_TYPE_SHORT = 0, // Short BLE UUID + UUID_TYPE_LONG = 1 // Full 128-bit UUID + }; + + UUID(void); + UUID(uint8_t const[16]); + UUID(uint16_t const); + virtual ~UUID(void); + + uint8_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG + uint8_t base[16]; // in case of custom + uint16_t value; // 16 bit uuid (byte 2-3 using with base) + + ble_error_t update(uint8_t const[16]); + ble_error_t update(uint16_t const); +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/blecommon.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/blecommon.h new file mode 100644 index 0000000000..30d8e28d70 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/blecommon.h @@ -0,0 +1,48 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __BLE_COMMON_H__ +#define __BLE_COMMON_H__ + +#define NRF51 +#define DEBUG_NRF_USER +#define BLE_STACK_SUPPORT_REQD +#define BOARD_PCA10001 + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/**************************************************************************/ +/*! + \brief Error codes for the BLE API +*/ +/**************************************************************************/ +typedef enum ble_error_e +{ + BLE_ERROR_NONE = 0, /**< No error */ + BLE_ERROR_BUFFER_OVERFLOW = 1, /**< The requested action would cause a buffer overflow and has been aborted */ + BLE_ERROR_NOT_IMPLEMENTED = 2, /**< Requested a feature that isn't yet implement or isn't supported by the target HW */ + BLE_ERROR_PARAM_OUT_OF_RANGE = 3 /**< One of the supplied parameters is outside the valid range */ +} ble_error_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/BLEDevice.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/BLEDevice.h new file mode 100644 index 0000000000..0a2030e331 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/BLEDevice.h @@ -0,0 +1,41 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __BLE_DEVICE_H__ +#define __BLE_DEVICE_H__ + +#include "mbed.h" +#include "blecommon.h" +#include "hw/Gap.h" +#include "hw/GattServer.h" + +/**************************************************************************/ +/*! + \brief + The base class used to abstract away BLE capable radio transceivers + or SOCs, to enable this BLE API to work with any radio transparently. +*/ +/**************************************************************************/ +class BLEDevice +{ + public: + virtual Gap& getGap() = 0; + virtual GattServer& getGattServer() = 0; + virtual ble_error_t init() = 0; + virtual ble_error_t reset(void) = 0; +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/Gap.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/Gap.h new file mode 100644 index 0000000000..644c4963f2 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/Gap.h @@ -0,0 +1,76 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __GAP_H__ +#define __GAP_H__ + +#include "mbed.h" +#include "blecommon.h" +#include "GapAdvertisingData.h" +#include "GapAdvertisingParams.h" +#include "GapEvents.h" + +/**************************************************************************/ +/*! + \brief + The base class used to abstract GAP functionality to a specific radio + transceiver, SOC or BLE Stack. +*/ +/**************************************************************************/ +class Gap +{ + private: + GapEvents *m_pEventHandler; + + public: + /* These functions must be defined in the sub-class */ + virtual ble_error_t setAdvertisingData(GapAdvertisingData &, GapAdvertisingData &) = 0; + virtual ble_error_t startAdvertising(GapAdvertisingParams &) = 0; + virtual ble_error_t stopAdvertising(void) = 0; + virtual ble_error_t disconnect(void) = 0; + + /* Describes the current state of the device (more than one bit can be set) */ + typedef struct GapState_s + { + unsigned advertising : 1; /**< The device is current advertising */ + unsigned connected : 1; /**< The peripheral is connected to a central device */ + } GapState_t; + + /* Event callback handlers */ + void setEventHandler(GapEvents *pEventHandler) {m_pEventHandler = pEventHandler;} + void handleEvent(GapEvents::gapEvent_e type) { + if (NULL == m_pEventHandler) + return; + switch(type) { + case GapEvents::GAP_EVENT_TIMEOUT: + state.advertising = 0; + m_pEventHandler->onTimeout(); + break; + case GapEvents::GAP_EVENT_CONNECTED: + state.connected = 1; + m_pEventHandler->onConnected(); + break; + case GapEvents::GAP_EVENT_DISCONNECTED: + state.connected = 0; + m_pEventHandler->onDisconnected(); + break; + } + } + + GapState_t state; +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GapEvents.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GapEvents.h new file mode 100644 index 0000000000..feba3d83f5 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GapEvents.h @@ -0,0 +1,71 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __GAP_EVENTS_H__ +#define __GAP_EVENTS_H__ + +#include "blecommon.h" +#include "mbed.h" + +/**************************************************************************/ +/*! + \brief + The base class used to abstract away the callback events that can be + triggered with the GAP. +*/ +/**************************************************************************/ +class GapEvents { + public: + /******************************************************************/ + /*! + \brief + Identifies GAP events generated by the radio HW when an event + callback occurs + */ + /******************************************************************/ + typedef enum gapEvent_e + { + GAP_EVENT_TIMEOUT = 1, /**< Advertising timed out before a connection was established */ + GAP_EVENT_CONNECTED = 2, /**< A connection was established with a central device */ + GAP_EVENT_DISCONNECTED = 3 /**< A connection was closed or lost with a central device */ + } gapEvent_t; + + /******************************************************************/ + /*! + \brief + Advertising timed out before a connection was established + */ + /******************************************************************/ + virtual void onTimeout(void) {} + + /******************************************************************/ + /*! + \brief + A connection was established with a central device + */ + /******************************************************************/ + virtual void onConnected(void) {} + + /******************************************************************/ + /*! + \brief + A connection was closed or lost with a central device + */ + /******************************************************************/ + virtual void onDisconnected(void) {} +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GattServer.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GattServer.h new file mode 100644 index 0000000000..0e3f0896b6 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GattServer.h @@ -0,0 +1,76 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __GATT_SERVER_H__ +#define __GATT_SERVER_H__ + +#include "mbed.h" +#include "blecommon.h" +#include "GattService.h" +#include "GattServerEvents.h" + +/**************************************************************************/ +/*! + \brief + The base class used to abstract GATT Server functionality to a specific + radio transceiver, SOC or BLE Stack. +*/ +/**************************************************************************/ +class GattServer +{ + private: + GattServerEvents *m_pEventHandler; + + public: + /* These functions must be defined in the sub-class */ + virtual ble_error_t addService(GattService &) = 0; + virtual ble_error_t readValue(uint16_t, uint8_t[], uint16_t) = 0; + virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t) = 0; + + // ToDo: For updateValue, check the CCCD to see if the value we are + // updating has the notify or indicate bits sent, and if BOTH are set + // be sure to call sd_ble_gatts_hvx() twice with notify then indicate! + // Strange use case, but valid and must be covered! + + /* Event callback handlers */ + void setEventHandler(GattServerEvents *pEventHandler) {m_pEventHandler = pEventHandler;} + void handleEvent(GattServerEvents::gattEvent_e type, uint16_t charHandle) { + if (NULL == m_pEventHandler) + return; + switch(type) { + case GattServerEvents::GATT_EVENT_DATA_SENT: + m_pEventHandler->onDataSent(charHandle); + break; + case GattServerEvents::GATT_EVENT_DATA_WRITTEN: + m_pEventHandler->onDataWritten(charHandle); + break; + case GattServerEvents::GATT_EVENT_UPDATES_ENABLED: + m_pEventHandler->onUpdatesEnabled(charHandle); + break; + case GattServerEvents::GATT_EVENT_UPDATES_DISABLED: + m_pEventHandler->onUpdatesDisabled(charHandle); + break; + case GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED: + m_pEventHandler->onConfirmationReceived(charHandle); + break; + } + } + + uint8_t serviceCount; + uint8_t characteristicCount; +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GattServerEvents.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GattServerEvents.h new file mode 100644 index 0000000000..a2219965a3 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/GattServerEvents.h @@ -0,0 +1,91 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __GATT_SERVER_EVENTS_H__ +#define __GATT_SERVER_EVENTS_H__ + +#include "blecommon.h" +#include "mbed.h" + +/**************************************************************************/ +/*! + \brief + The base class used to abstract away the callback events that can be + triggered with the GATT Server. +*/ +/**************************************************************************/ +class GattServerEvents { + public: + /******************************************************************/ + /*! + \brief + Identifies GATT events generated by the radio HW when an event + callback occurs + */ + /******************************************************************/ + typedef enum gattEvent_e + { + GATT_EVENT_DATA_SENT = 1, /**< Fired when a msg was successfully sent out (notify only?) */ + GATT_EVENT_DATA_WRITTEN = 2, /**< Client wrote data to Server (separate into char and descriptor writes?) */ + GATT_EVENT_UPDATES_ENABLED = 3, /**< Notify/Indicate Enabled in CCCD */ + GATT_EVENT_UPDATES_DISABLED = 4, /**< Notify/Indicate Disabled in CCCD */ + GATT_EVENT_CONFIRMATION_RECEIVED = 5 /**< Response received from Indicate message */ + } gattEvent_t; + + /******************************************************************/ + /*! + \brief + A message was successfully transmitted + */ + /******************************************************************/ + virtual void onDataSent(uint16_t charHandle) {} + + /******************************************************************/ + /*! + \brief + The GATT client (the phone, tablet, etc.) wrote data to a + characteristic or descriptor on the GATT Server (the peripheral + device). + */ + /******************************************************************/ + virtual void onDataWritten(uint16_t charHandle) {} + + /******************************************************************/ + /*! + \brief + A Notify or Indicate flag was enabled in the CCCD + */ + /******************************************************************/ + virtual void onUpdatesEnabled(uint16_t charHandle) {} + + /******************************************************************/ + /*! + \brief + A Notify or Indicate flag was disabled in the CCCD + */ + /******************************************************************/ + virtual void onUpdatesDisabled(uint16_t charHandle) {} + + /******************************************************************/ + /*! + \brief + A confirmation response was received from an Indicate message + */ + /******************************************************************/ + virtual void onConfirmationReceived(uint16_t charHandle) {} +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle.cpp new file mode 100644 index 0000000000..f0ecadb670 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle.cpp @@ -0,0 +1,220 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ +#include "common/common.h" + +#include "app_timer.h" +#include "btle.h" + +#include "ble_stack_handler_types.h" +#include "ble_radio_notification.h" +#include "ble_flash.h" +#include "ble_bondmngr.h" +#include "ble_conn_params.h" + +#include "btle_gap.h" +#include "btle_advertising.h" +#include "custom/custom_helper.h" + +#include "nordic_common.h" +#include "softdevice_handler.h" +#include "pstorage.h" + +#include "hw/GapEvents.h" +#include "hw/nRF51822n/nRF51Gap.h" +#include "hw/nRF51822n/nRF51GattServer.h" + +static void service_error_callback(uint32_t nrf_error); +void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name); +void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); + +static error_t bond_manager_init(void); + +static void btle_handler(ble_evt_t * p_ble_evt); + +/**************************************************************************/ +/*! + +*/ +/**************************************************************************/ +static void sys_evt_dispatch(uint32_t sys_evt) +{ + pstorage_sys_event_handler(sys_evt); +} + +/**************************************************************************/ +/*! + @brief Initialises BTLE and the underlying HW/SoftDevice + + @returns +*/ +/**************************************************************************/ +error_t btle_init(void) +{ + APP_TIMER_INIT(0, 8, 5, false); + SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false); + + ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler) ); + ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch) ); + + bond_manager_init(); + btle_gap_init(); + + return ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief + + @param[in] p_ble_evt + + @returns +*/ +/**************************************************************************/ +static void btle_handler(ble_evt_t * p_ble_evt) +{ + /* Library service handlers */ + ble_bondmngr_on_ble_evt(p_ble_evt); + ble_conn_params_on_ble_evt(p_ble_evt); + + /* Custom event handler */ + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + nRF51GattServer::getInstance().m_connectionHandle = p_ble_evt->evt.gap_evt.conn_handle; + nRF51Gap::getInstance().handleEvent(GapEvents::GAP_EVENT_CONNECTED); + break; + + case BLE_GAP_EVT_DISCONNECTED: + // Since we are not in a connection and have not started advertising, store bonds + nRF51GattServer::getInstance().m_connectionHandle = BLE_CONN_HANDLE_INVALID; + ASSERT_STATUS_RET_VOID ( ble_bondmngr_bonded_centrals_store() ); + nRF51Gap::getInstance().handleEvent(GapEvents::GAP_EVENT_DISCONNECTED); + break; + + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: + { + ble_gap_sec_params_t sec_params = { 0 }; + + sec_params.timeout = 30 ; /**< Timeout for Pairing Request or Security Request (in seconds). */ + sec_params.bond = 1 ; /**< Perform bonding. */ + sec_params.mitm = CFG_BLE_SEC_PARAM_MITM ; + sec_params.io_caps = CFG_BLE_SEC_PARAM_IO_CAPABILITIES ; + sec_params.oob = CFG_BLE_SEC_PARAM_OOB ; + sec_params.min_key_size = CFG_BLE_SEC_PARAM_MIN_KEY_SIZE ; + sec_params.max_key_size = CFG_BLE_SEC_PARAM_MAX_KEY_SIZE ; + + ASSERT_STATUS_RET_VOID ( sd_ble_gap_sec_params_reply(nRF51GattServer::getInstance().m_connectionHandle, BLE_GAP_SEC_STATUS_SUCCESS, &sec_params) ); + } + break; + + case BLE_GAP_EVT_TIMEOUT: + if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT) + { + nRF51Gap::getInstance().handleEvent(GapEvents::GAP_EVENT_TIMEOUT); + } + break; + + case BLE_GATTC_EVT_TIMEOUT: + case BLE_GATTS_EVT_TIMEOUT: + // Disconnect on GATT Server and Client timeout events. + // ASSERT_STATUS_RET_VOID (sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION)); + break; + + default: + break; + } + + nRF51GattServer::getInstance().hwCallback(p_ble_evt); +} + +/**************************************************************************/ +/*! + @brief Initialises the bond manager + + @note Bond data will be cleared on reset if the bond delete + button is pressed during initialisation (the button is + defined as CFG_BLE_BOND_DELETE_BUTTON_NUM). + + @returns +*/ +/**************************************************************************/ +static error_t bond_manager_init(void) +{ + ble_bondmngr_init_t bond_para = { 0 }; + + ASSERT_STATUS ( pstorage_init() ); + + bond_para.flash_page_num_bond = CFG_BLE_BOND_FLASH_PAGE_BOND ; + bond_para.flash_page_num_sys_attr = CFG_BLE_BOND_FLASH_PAGE_SYS_ATTR ; + //bond_para.bonds_delete = boardButtonCheck(CFG_BLE_BOND_DELETE_BUTTON_NUM) ; + bond_para.evt_handler = NULL ; + bond_para.error_handler = service_error_callback ; + + ASSERT_STATUS( ble_bondmngr_init( &bond_para ) ); + + /* Init radio active/inactive notification to flash (to only perform flashing when the radio is inactive) */ + // ASSERT_STATUS( ble_radio_notification_init(NRF_APP_PRIORITY_HIGH, + // NRF_RADIO_NOTIFICATION_DISTANCE_4560US, + // ble_flash_on_radio_active_evt) ); + + return ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief + @param[in] nrf_error + @returns +*/ +/**************************************************************************/ +static void service_error_callback(uint32_t nrf_error) +{ + ASSERT_STATUS_RET_VOID( nrf_error ); +} + +/**************************************************************************/ +/*! + @brief Callback when an error occurs inside the SoftDevice + + @param[in] line_num + @param[in] p-file_name + + @returns +*/ +/**************************************************************************/ +void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) +{ + ASSERT(false, (void) 0); +} + +/**************************************************************************/ +/*! + @brief Handler for general errors above the SoftDevice layer. + Typically we can' recover from this so we do a reset. + + @param[in] error_code + @param[in] line_num + @param[in] p-file_name + + @returns +*/ +/**************************************************************************/ +void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + ASSERT_STATUS_RET_VOID( error_code ); + NVIC_SystemReset(); +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle.h new file mode 100644 index 0000000000..c6ca78d700 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle.h @@ -0,0 +1,35 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 _BTLE_H_ +#define _BTLE_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#include "common/common.h" + +#include "ble_srv_common.h" +#include "ble.h" + +error_t btle_init(void); + +#ifdef __cplusplus + } +#endif + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_advertising.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_advertising.cpp new file mode 100644 index 0000000000..39ea6d8b96 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_advertising.cpp @@ -0,0 +1,43 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ +#include "common/common.h" + +#include "ble_advdata.h" +#include "btle.h" + +/**************************************************************************/ +/*! + @brief Starts the advertising process + + @returns +*/ +/**************************************************************************/ +error_t btle_advertising_start(void) +{ + ble_gap_adv_params_t adv_para = { 0 }; + + /* Set the default advertising parameters */ + adv_para.type = BLE_GAP_ADV_TYPE_ADV_IND ; + adv_para.p_peer_addr = NULL ; /* Undirected advertising */ + adv_para.fp = BLE_GAP_ADV_FP_ANY ; + adv_para.p_whitelist = NULL ; + adv_para.interval = (CFG_GAP_ADV_INTERVAL_MS*8)/5 ; /* Advertising interval in units of 0.625 ms */ + adv_para.timeout = CFG_GAP_ADV_TIMEOUT_S ; + + ASSERT_STATUS( sd_ble_gap_adv_start(&adv_para) ); + + return ERROR_NONE; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_advertising.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_advertising.h new file mode 100644 index 0000000000..61ea01f24c --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_advertising.h @@ -0,0 +1,24 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 _BTLE_ADVERTISING_H_ +#define _BTLE_ADVERTISING_H_ + +#include "common/common.h" + +error_t btle_advertising_start(void); + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_gap.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_gap.cpp new file mode 100644 index 0000000000..6144078f1d --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_gap.cpp @@ -0,0 +1,90 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ +#include "common/common.h" + +#include "app_timer.h" +#include "ble_gap.h" +#include "ble_conn_params.h" + +static inline uint32_t msec_to_1_25msec(uint32_t interval_ms) ATTR_ALWAYS_INLINE ATTR_CONST; +static void error_callback(uint32_t nrf_error); + +/**************************************************************************/ +/*! + @brief Initialise GAP in the underlying SoftDevice + + @returns +*/ +/**************************************************************************/ +error_t btle_gap_init(void) +{ + ble_gap_conn_params_t gap_conn_params = { 0 }; + + gap_conn_params.min_conn_interval = msec_to_1_25msec(CFG_GAP_CONNECTION_MIN_INTERVAL_MS) ; // in 1.25ms unit + gap_conn_params.max_conn_interval = msec_to_1_25msec(CFG_GAP_CONNECTION_MAX_INTERVAL_MS) ; // in 1.25ms unit + gap_conn_params.slave_latency = CFG_GAP_CONNECTION_SLAVE_LATENCY ; + gap_conn_params.conn_sup_timeout = CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS / 10 ; // in 10ms unit + + ble_gap_conn_sec_mode_t sec_mode; + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed + + ASSERT_STATUS( sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *) CFG_GAP_LOCAL_NAME, strlen(CFG_GAP_LOCAL_NAME)) ); + ASSERT_STATUS( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE) ); + ASSERT_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params) ); + ASSERT_STATUS( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL) ); + + /* Connection Parameters */ + enum { + FIRST_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER), + NEXT_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER), + MAX_UPDATE_COUNT = 3 + }; + + ble_conn_params_init_t cp_init = { 0 }; + + cp_init.p_conn_params = NULL ; + cp_init.first_conn_params_update_delay = FIRST_UPDATE_DELAY ; + cp_init.next_conn_params_update_delay = NEXT_UPDATE_DELAY ; + cp_init.max_conn_params_update_count = MAX_UPDATE_COUNT ; + cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID ; + cp_init.disconnect_on_fail = true ; + cp_init.evt_handler = NULL ; + cp_init.error_handler = error_callback; + + ASSERT_STATUS ( ble_conn_params_init(&cp_init) ); + + return ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Converts msecs to an integer representing 1.25ms units + + @param[in] ms + The number of milliseconds to conver to 1.25ms units + + @returns The number of 1.25ms units in the supplied number of ms +*/ +/**************************************************************************/ +static inline uint32_t msec_to_1_25msec(uint32_t interval_ms) +{ + return (interval_ms * 4) / 5 ; +} + +static void error_callback(uint32_t nrf_error) +{ + ASSERT_STATUS_RET_VOID( nrf_error ); +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_gap.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_gap.h new file mode 100644 index 0000000000..03fce0c61b --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/btle_gap.h @@ -0,0 +1,24 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 _BTLE_GAP_H_ +#define _BTLE_GAP_H_ + +#include "common/common.h" + +error_t btle_gap_init(void); + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/custom/custom_helper.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/custom/custom_helper.cpp new file mode 100644 index 0000000000..d8a38478e9 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/custom/custom_helper.cpp @@ -0,0 +1,163 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + + #include "custom_helper.h" + +/**************************************************************************/ +/*! + @brief Adds the base UUID to the custom service. All UUIDs used + by this service are based on this 128-bit UUID. + + @note This UUID needs to be added to the SoftDevice stack before + adding the service's primary service via + 'sd_ble_gatts_service_add' + + @param[in] p_uuid_base A pointer to the 128-bit UUID array (8*16) + + @returns The UUID type. + A return value of 0 should be considered an error. + + @retval 0x00 BLE_UUID_TYPE_UNKNOWN + @retval 0x01 BLE_UUID_TYPE_BLE + @retval 0x02 BLE_UUID_TYPE_VENDOR_BEGIN + + @section EXAMPLE + @code + + // Take note that bytes 2/3 are blank since these are used to identify + // the primary service and individual characteristics + #define CFG_CUSTOM_UUID_BASE "\x6E\x40\x00\x00\xB5\xA3\xF3\x93\xE0\xA9\xE5\x0E\x24\xDC\xCA\x9E" + + uint8_t uuid_type = custom_add_uuid_base(CFG_CUSTOM_UUID_BASE); + ASSERT(uuid_type > 0, ERROR_NOT_FOUND); + + // We can now safely add the primary service and any characteristics + // for our custom service ... + + @endcode +*/ +/**************************************************************************/ +uint8_t custom_add_uuid_base(uint8_t const * const p_uuid_base) +{ + ble_uuid128_t base_uuid; + uint8_t uuid_type = 0; + + /* Reverse the bytes since ble_uuid128_t is LSB */ + for(uint8_t i=0; i<16; i++) + { + base_uuid.uuid128[i] = p_uuid_base[15-i]; + } + + ASSERT_INT( ERROR_NONE, sd_ble_uuid_vs_add( &base_uuid, &uuid_type ), 0); + + return uuid_type; +} + +/**************************************************************************/ +/*! + +*/ +/**************************************************************************/ +error_t custom_decode_uuid_base(uint8_t const * const p_uuid_base, ble_uuid_t * p_uuid) +{ + uint8_t uuid_base_le[16]; + + /* Reverse the bytes since ble_uuid128_t is LSB */ + for(uint8_t i=0; i<16; i++) + { + uuid_base_le[i] = p_uuid_base[15-i]; + } + + ASSERT_STATUS( sd_ble_uuid_decode(16, uuid_base_le, p_uuid) ); + + return ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Adds a new characteristic to the custom service, assigning + properties, a UUID add-on value, etc. + + @param[in] service_handle + @param[in] p_uuid The 16-bit value to add to the base UUID + for this characteristic (normally >1 + since 1 is typically used by the primary + service). + @param[in] char_props The characteristic properties, as + defined by ble_gatt_char_props_t + @param[in] max_length The maximum length of this characeristic + @param[in] p_char_handle + + @returns + @retval ERROR_NONE Everything executed normally +*/ +/**************************************************************************/ +error_t custom_add_in_characteristic(uint16_t service_handle, ble_uuid_t* p_uuid, uint8_t properties, + uint8_t *p_data, uint16_t min_length, uint16_t max_length, + ble_gatts_char_handles_t* p_char_handle) +{ + /* Characteristic metadata */ + ble_gatts_attr_md_t cccd_md; + ble_gatt_char_props_t char_props; + + memcpy(&char_props, &properties, 1); + + if ( char_props.notify || char_props.indicate ) + { + /* Notification requires cccd */ + memclr_( &cccd_md, sizeof(ble_gatts_attr_md_t) ); + cccd_md.vloc = BLE_GATTS_VLOC_STACK; + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); + } + + ble_gatts_char_md_t char_md = { 0 }; + + char_md.char_props = char_props; + char_md.p_cccd_md = (char_props.notify || char_props.indicate ) ? &cccd_md : NULL; + + /* Attribute declaration */ + ble_gatts_attr_md_t attr_md = { 0 }; + + attr_md.vloc = BLE_GATTS_VLOC_STACK; + attr_md.vlen = (min_length == max_length) ? 0 : 1; + + if ( char_props.read || char_props.notify || char_props.indicate ) + { + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); + } + + if ( char_props.write ) + { + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); + } + + ble_gatts_attr_t attr_char_value = { 0 }; + + attr_char_value.p_uuid = p_uuid; + attr_char_value.p_attr_md = &attr_md; + attr_char_value.init_len = min_length; + attr_char_value.max_len = max_length; + attr_char_value.p_value = p_data; + + + ASSERT_STATUS ( sd_ble_gatts_characteristic_add(service_handle, + &char_md, + &attr_char_value, + p_char_handle) ); + + return ERROR_NONE; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/custom/custom_helper.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/custom/custom_helper.h new file mode 100644 index 0000000000..d77129653b --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/btle/custom/custom_helper.h @@ -0,0 +1,38 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 _CUSTOM_HELPER_H_ +#define _CUSTOM_HELPER_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#include "common/common.h" +#include "ble.h" + +uint8_t custom_add_uuid_base(uint8_t const * const p_uuid_base); +error_t custom_decode_uuid(uint8_t const * const p_uuid_base, ble_uuid_t * p_uuid); + +error_t custom_add_in_characteristic(uint16_t service_handle, ble_uuid_t* p_uuid, uint8_t properties, + uint8_t *p_data, uint16_t min_length, uint16_t max_length, + ble_gatts_char_handles_t* p_char_handle); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/ansi_escape.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/ansi_escape.h new file mode 100644 index 0000000000..8a9377097c --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/ansi_escape.h @@ -0,0 +1,103 @@ +/**************************************************************************/ +/*! + @file ansi_esc_code.h + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, hathach (tinyusb.org) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This file is part of the tinyusb stack. +*/ +/**************************************************************************/ + +/** \file + * \brief TBD + * + * \note TBD + */ + +/** \ingroup TBD + * \defgroup TBD + * \brief TBD + * + * @{ + */ + +#ifndef _ANSI_ESC_CODE_H_ +#define _ANSI_ESC_CODE_H_ + + +#ifdef __cplusplus + extern "C" { +#endif + +#define CSI_CODE(seq) "\33[" seq +#define CSI_SGR(x) CSI_CODE(#x) "m" + +//------------- Cursor movement -------------// +#define ANSI_CURSOR_UP(n) CSI_CODE(#n "A") +#define ANSI_CURSOR_DOWN(n) CSI_CODE(#n "B") +#define ANSI_CURSOR_FORWARD(n) CSI_CODE(#n "C") +#define ANSI_CURSOR_BACKWARD(n) CSI_CODE(#n "D") +#define ANSI_CURSOR_LINE_DOWN(n) CSI_CODE(#n "E") +#define ANSI_CURSOR_LINE_UP(n) CSI_CODE(#n "F") +#define ANSI_CURSOR_POSITION(n, m) CSI_CODE(#n ";" #m "H") + +#define ANSI_ERASE_SCREEN(n) CSI_CODE(#n "J") +#define ANSI_ERASE_LINE(n) CSI_CODE(#n "K") + +/** text color */ +#define ANSI_TEXT_BLACK CSI_SGR(30) +#define ANSI_TEXT_RED CSI_SGR(31) +#define ANSI_TEXT_GREEN CSI_SGR(32) +#define ANSI_TEXT_YELLOW CSI_SGR(33) +#define ANSI_TEXT_BLUE CSI_SGR(34) +#define ANSI_TEXT_MAGENTA CSI_SGR(35) +#define ANSI_TEXT_CYAN CSI_SGR(36) +#define ANSI_TEXT_WHITE CSI_SGR(37) +#define ANSI_TEXT_DEFAULT CSI_SGR(39) + +/** background color */ +#define ANSI_BG_BLACK CSI_SGR(40) +#define ANSI_BG_RED CSI_SGR(41) +#define ANSI_BG_GREEN CSI_SGR(42) +#define ANSI_BG_YELLOW CSI_SGR(43) +#define ANSI_BG_BLUE CSI_SGR(44) +#define ANSI_BG_MAGENTA CSI_SGR(45) +#define ANSI_BG_CYAN CSI_SGR(46) +#define ANSI_BG_WHITE CSI_SGR(47) +#define ANSI_BG_DEFAULT CSI_SGR(49) + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_ANSI_ESC_CODE_H_ */ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/assertion.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/assertion.h new file mode 100644 index 0000000000..698e27dd02 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/assertion.h @@ -0,0 +1,200 @@ +/**************************************************************************/ +/*! + @file assertion.h + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, K. Townsend (microBuilder.eu) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ + +/** \file + * \brief TBD + * + * \note TBD + */ + +/** \ingroup TBD + * \defgroup TBD + * \brief TBD + * + * @{ + */ + +#ifndef _ASSERTION_H_ +#define _ASSERTION_H_ + +#include "projectconfig.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +static inline void debugger_breakpoint(void) ATTR_ALWAYS_INLINE; +static inline void debugger_breakpoint(void) +{ +#ifndef _TEST_ + __asm("BKPT #0\n"); +#endif +} + +//--------------------------------------------------------------------+ +// Compile-time Assert +//--------------------------------------------------------------------+ +#if defined __COUNTER__ && __COUNTER__ != __COUNTER__ + #define _ASSERT_COUNTER __COUNTER__ +#else + #define _ASSERT_COUNTER __LINE__ +#endif + +#define ASSERT_STATIC(const_expr, message) enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) } + +//--------------------------------------------------------------------+ +// Assert Helper +//--------------------------------------------------------------------+ +//#ifndef _TEST_ +// #define ASSERT_MESSAGE(format, ...)\ +// _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) +//#else +// #define ASSERT_MESSAGE(format, ...)\ +// _PRINTF("%d:note: Assert " format "\n", __LINE__, __VA_ARGS__) +//#endif + +#if CFG_DEBUG == 3 + #define ASSERT_MESSAGE(format, ...) debugger_breakpoint() +#elif CFG_DEBUG == 2 + #define ASSERT_MESSAGE(format, ...) printf("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) +#else + #define ASSERT_MESSAGE(format, ...) +#endif + +#define ASSERT_ERROR_HANDLER(x, para) \ + return (x) + +#define ASSERT_DEFINE_WITH_HANDLER(error_handler, handler_para, setup_statement, condition, error, format, ...) \ + do{\ + setup_statement;\ + if (!(condition)) {\ + ASSERT_MESSAGE(format, __VA_ARGS__);\ + error_handler(error, handler_para);\ + }\ + }while(0) + +#define ASSERT_DEFINE(...) ASSERT_DEFINE_WITH_HANDLER(ASSERT_ERROR_HANDLER, NULL, __VA_ARGS__) + +//--------------------------------------------------------------------+ +// error_t Status Assert TODO use ASSERT_DEFINE +//--------------------------------------------------------------------+ +#define ASSERT_STATUS_MESSAGE(sts, message) \ + ASSERT_DEFINE(error_t status = (error_t)(sts),\ + ERROR_NONE == status, status, "%s: %s", ErrorStr[status], message) + +#define ASSERT_STATUS(sts) \ + ASSERT_DEFINE(error_t status = (error_t)(sts),\ + ERROR_NONE == status, status, "error = %d", status) + +#define ASSERT_STATUS_RET_VOID(sts) \ + ASSERT_DEFINE(error_t status = (error_t)(sts),\ + ERROR_NONE == status, (void) 0, "error = %d", status) + +//--------------------------------------------------------------------+ +// Logical Assert +//--------------------------------------------------------------------+ +#define ASSERT(...) ASSERT_TRUE(__VA_ARGS__) +#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false") +#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true") + +//--------------------------------------------------------------------+ +// Pointer Assert +//--------------------------------------------------------------------+ +#define ASSERT_PTR(...) ASSERT_PTR_NOT_NULL(__VA_ARGS__) +#define ASSERT_PTR_NOT_NULL(pointer, error) ASSERT_DEFINE( , NULL != (pointer), error, "%s", "pointer is NULL") +#define ASSERT_PTR_NULL(pointer, error) ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is not NULL") + +//--------------------------------------------------------------------+ +// Integral Assert +//--------------------------------------------------------------------+ +#define ASSERT_XXX_EQUAL(type_format, expected, actual, error) \ + ASSERT_DEFINE(\ + uint32_t exp = (expected); uint32_t act = (actual),\ + exp==act,\ + error,\ + "expected " type_format ", actual " type_format, exp, act) + +#define ASSERT_XXX_WITHIN(type_format, lower, upper, actual, error) \ + ASSERT_DEFINE(\ + uint32_t low = (lower); uint32_t up = (upper); uint32_t act = (actual),\ + (low <= act) && (act <= up),\ + error,\ + "expected within " type_format " - " type_format ", actual " type_format, low, up, act) + +//--------------------------------------------------------------------+ +// Integer Assert +//--------------------------------------------------------------------+ +#define ASSERT_INT(...) ASSERT_INT_EQUAL(__VA_ARGS__) +#define ASSERT_INT_EQUAL(...) ASSERT_XXX_EQUAL("%d", __VA_ARGS__) +#define ASSERT_INT_WITHIN(...) ASSERT_XXX_WITHIN("%d", __VA_ARGS__) + +//--------------------------------------------------------------------+ +// Hex Assert +//--------------------------------------------------------------------+ +#define ASSERT_HEX(...) ASSERT_HEX_EQUAL(__VA_ARGS__) +#define ASSERT_HEX_EQUAL(...) ASSERT_XXX_EQUAL("0x%x", __VA_ARGS__) +#define ASSERT_HEX_WITHIN(...) ASSERT_XXX_WITHIN("0x%x", __VA_ARGS__) + +//--------------------------------------------------------------------+ +// Bin Assert +//--------------------------------------------------------------------+ +#define BIN8_PRINTF_PATTERN "%d%d%d%d%d%d%d%d" +#define BIN8_PRINTF_CONVERT(byte) \ + ((byte) & 0x80 ? 1 : 0), \ + ((byte) & 0x40 ? 1 : 0), \ + ((byte) & 0x20 ? 1 : 0), \ + ((byte) & 0x10 ? 1 : 0), \ + ((byte) & 0x08 ? 1 : 0), \ + ((byte) & 0x04 ? 1 : 0), \ + ((byte) & 0x02 ? 1 : 0), \ + ((byte) & 0x01 ? 1 : 0) + +#define ASSERT_BIN8(...) ASSERT_BIN8_EQUAL(__VA_ARGS__) +#define ASSERT_BIN8_EQUAL(expected, actual, error)\ + ASSERT_DEFINE(\ + uint8_t exp = (expected); uint8_t act = (actual),\ + exp==act,\ + error,\ + "expected " BIN8_PRINTF_PATTERN ", actual " BIN8_PRINTF_PATTERN, BIN8_PRINTF_CONVERT(exp), BIN8_PRINTF_CONVERT(act) ) + +#ifdef __cplusplus +} +#endif + +#endif /* _ASSERTION_H_ */ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/binary.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/binary.h new file mode 100644 index 0000000000..585787eb2f --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/binary.h @@ -0,0 +1,96 @@ +/**************************************************************************/ +/*! + @file binary.h + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, K. Townsend (microBuilder.eu) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ + +/** \ingroup TBD + * \defgroup TBD + * \brief TBD + * + * @{ + */ + +#ifndef _BINARY_H_ +#define _BINARY_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +/// n-th Bit +#define BIT(n) (1 << (n)) + +/// set n-th bit of x to 1 +#define BIT_SET(x, n) ( (x) | BIT(n) ) + +/// clear n-th bit of x +#define BIT_CLR(x, n) ( (x) & (~BIT(n)) ) + +/// test n-th bit of x +#define BIT_TEST(x, n) ( (x) & BIT(n) ) + +#if defined(__GNUC__) && !defined(__CC_ARM) // keil does not support binary format + +#define BIN8(x) ((uint8_t) (0b##x)) +#define BIN16(b1, b2) ((uint16_t) (0b##b1##b2)) +#define BIN32(b1, b2, b3, b4) ((uint32_t) (0b##b1##b2##b3##b4)) + +#else + +// internal macro of B8, B16, B32 +#define _B8__(x) (((x&0x0000000FUL)?1:0) \ + +((x&0x000000F0UL)?2:0) \ + +((x&0x00000F00UL)?4:0) \ + +((x&0x0000F000UL)?8:0) \ + +((x&0x000F0000UL)?16:0) \ + +((x&0x00F00000UL)?32:0) \ + +((x&0x0F000000UL)?64:0) \ + +((x&0xF0000000UL)?128:0)) + +#define BIN8(d) ((uint8_t) _B8__(0x##d##UL)) +#define BIN16(dmsb,dlsb) (((uint16_t)BIN8(dmsb)<<8) + BIN8(dlsb)) +#define BIN32(dmsb,db2,db3,dlsb) \ + (((uint32_t)BIN8(dmsb)<<24) \ + + ((uint32_t)BIN8(db2)<<16) \ + + ((uint32_t)BIN8(db3)<<8) \ + + BIN8(dlsb)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _BINARY_H_ */ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/ble_error.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/ble_error.h new file mode 100644 index 0000000000..36deb33080 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/ble_error.h @@ -0,0 +1,151 @@ +/**************************************************************************/ +/*! + @file ble_error.h + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, K. Townsend (microBuilder.eu) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ + +/** \file + * \brief Error Header + * + * \note TBD + */ + +/** \ingroup Group_Common + * \defgroup Group_Error Error Codes + * @{ + */ + +#ifndef _BLE_ERROR_H_ +#define _BLE_ERROR_H_ + +#include "projectconfig.h" + +#ifdef __cplusplus + extern "C" { +#endif + +typedef enum +{ + /*======================================================================= + NORDIC GLOBAL ERRORS 0x0000 .. 0x00FF + ----------------------------------------------------------------------- + Errors mapped from nrf_error.h + -----------------------------------------------------------------------*/ + ERROR_NONE = 0x0000 , ///< Successful command + ERROR_SVC_HANDLER_MISSING = 0x0001 , ///< SVC handler is missing + ERROR_SOFTDEVICE_NOT_ENABLED = 0x0002 , ///< SoftDevice has not been enabled + ERROR_INTERNAL = 0x0003 , ///< Internal Error + ERROR_NO_MEM = 0x0004 , ///< No Memory for operation + ERROR_NOT_FOUND = 0x0005 , ///< Not found + ERROR_NOT_SUPPORTED = 0x0006 , ///< Not supported + ERROR_INVALID_PARAM = 0x0007 , ///< Invalid Parameter + ERROR_INVALID_STATE = 0x0008 , ///< Invalid state, operation disallowed in this state + ERROR_INVALID_LENGTH = 0x0009 , ///< Invalid Length + ERROR_INVALID_FLAGS = 0x000A , ///< Invalid Flags + ERROR_INVALID_DATA = 0x000B , ///< Invalid Data + ERROR_DATA_SIZE = 0x000C , ///< Data size exceeds limit + ERROR_TIMEOUT = 0x000D , ///< Operation timed out + ERROR_NULL = 0x000E , ///< Null Pointer + ERROR_FORBIDDEN = 0x000F , ///< Forbidden Operation + ERROR_INVALID_ADDR = 0x0010 , ///< Bad Memory Address + ERROR_BUSY = 0x0011 , ///< Busy + /*=======================================================================*/ + + ERROR_INVALIDPARAMETER = 0x0100 , /**< An invalid parameter value was provided */ + ERROR_I2C_XFER_FAILED = 0x0101 , /**< an failed attempt to make I2C transfer */ + + /*======================================================================= + SIMPLE BINARY PROTOCOL ERRORS 0x0120 .. 0x013F + ----------------------------------------------------------------------- + Errors relating to the simple binary protocol (/src//protocol) + -----------------------------------------------------------------------*/ + ERROR_PROT_INVALIDMSGTYPE = 0x121, /**< Unexpected msg type encountered */ + ERROR_PROT_INVALIDCOMMANDID = 0x122, /**< Unknown or out of range command ID */ + ERROR_PROT_INVALIDPAYLOAD = 0x123, /**< Message payload has a problem (invalid len, etc.) */ + /*=======================================================================*/ + + //------------- based on Nordic SDM nrf_error_sdm.h -------------// + ERROR_SDM_LFCLK_SOURCE_UNKNOWN = 0x1000 , ///< Unknown lfclk source + ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION = 0x1001 , ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts) + ERROR_SDM_INCORRECT_CLENR0 = 0x1002 , ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing) + + //------------- based on Nordic SOC nrf_error_soc.h -------------// + /* Mutex Errors */ + ERROR_SOC_MUTEX_ALREADY_TAKEN = 0x2000 , ///< Mutex already taken + + /* NVIC errors */ + ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE = 0x2001 , ///< NVIC interrupt not available + ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED = 0x2002 , ///< NVIC interrupt priority not allowed + ERROR_SOC_NVIC_SHOULD_NOT_RETURN = 0x2003 , ///< NVIC should not return + + /* Power errors */ + ERROR_SOC_POWER_MODE_UNKNOWN = 0x2004 , ///< Power mode unknown + ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN = 0x2005 , ///< Power POF threshold unknown + ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN = 0x2006 , ///< Power off should not return + + /* Rand errors */ + ERROR_SOC_RAND_NOT_ENOUGH_VALUES = 0x2007 , ///< RAND not enough values + + /* PPI errors */ + ERROR_SOC_PPI_INVALID_CHANNEL = 0x2008 , ///< Invalid PPI Channel + ERROR_SOC_PPI_INVALID_GROUP = 0x2009 , ///< Invalid PPI Group + + //------------- based on Nordic STK (ble) ble_err.h -------------// + ERROR_BLE_INVALID_CONN_HANDLE = 0x3001 , /**< Invalid connection handle. */ + ERROR_BLE_INVALID_ATTR_HANDLE = 0x3002 , /**< Invalid attribute handle. */ + ERROR_BLE_NO_TX_BUFFERS = 0x3003 , /**< Buffer capacity exceeded. */ + + // L2CAP + ERROR_BLE_L2CAP_CID_IN_USE = 0x3100 , /**< CID already in use. */ + + // GAP + ERROR_BLE_GAP_UUID_LIST_MISMATCH = 0x3200 , /**< UUID list does not contain an integral number of UUIDs. */ + ERROR_BLE_GAP_DISCOVERABLE_WITH_WHITELIST = 0x3201 , /**< Use of Whitelist not permitted with discoverable advertising. */ + ERROR_BLE_GAP_INVALID_BLE_ADDR = 0x3202 , /**< The upper two bits of the address do not correspond to the specified address type. */ + + // GATTC + ERROR_BLE_GATTC_PROC_NOT_PERMITTED = 0x3300 , + + // GATTS + ERROR_BLEGATTS_INVALID_ATTR_TYPE = 0x3400 , /**< Invalid attribute type. */ + ERROR_BLEGATTS_SYS_ATTR_MISSING = 0x3401 , /**< System Attributes missing. */ + +}error_t; + +#ifdef __cplusplus + } +#endif + +#endif /* _BLE_ERROR_H_ */ + + /** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/common.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/common.h new file mode 100644 index 0000000000..6002c6dfb7 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/common.h @@ -0,0 +1,236 @@ +/**************************************************************************/ +/*! + @file common.h + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, K. Townsend (microBuilder.eu) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ + +/** \defgroup Group_Common Common Files + * @{ + * + * \defgroup Group_CommonH common.h + * + * @{ + */ + +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +//--------------------------------------------------------------------+ +// INCLUDES +//--------------------------------------------------------------------+ + +//------------- Standard Header -------------// +#include +#include +#include +#include +#include + +//------------- General Header -------------// +#include "projectconfig.h" +#include "compiler.h" +#include "assertion.h" +#include "binary.h" +#include "ble_error.h" + +//------------- MCU header -------------// +//#include "nrf.h" + +//--------------------------------------------------------------------+ +// TYPEDEFS +//--------------------------------------------------------------------+ +typedef unsigned char byte_t; +typedef float float32_t; +typedef double float64_t; + +//--------------------------------------------------------------------+ +// MACROS +//--------------------------------------------------------------------+ +#define STRING_(x) #x // stringify without expand +#define XSTRING_(x) STRING_(x) // expand then stringify +#define STRING_CONCAT_(a, b) a##b // concat without expand +#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) // expand then concat + +#define U16_HIGH_U8(u16) ((uint8_t) (((u16) >> 8) & 0x00ff)) +#define U16_LOW_U8(u16) ((uint8_t) ((u16) & 0x00ff)) +#define U16_TO_U8S_BE(u16) U16_HIGH_U8(u16), U16_LOW_U8(u16) +#define U16_TO_U8S_LE(u16) U16_LOW_U8(u16), U16_HIGH_U8(u16) + +#define U32_B1_U8(u32) ((uint8_t) (((u32) >> 24) & 0x000000ff)) // MSB +#define U32_B2_U8(u32) ((uint8_t) (((u32) >> 16) & 0x000000ff)) +#define U32_B3_U8(u32) ((uint8_t) (((u32) >> 8) & 0x000000ff)) +#define U32_B4_U8(u32) ((uint8_t) ((u32) & 0x000000ff)) // LSB + +#define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32) +#define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32) + +//--------------------------------------------------------------------+ +// INLINE FUNCTION +//--------------------------------------------------------------------+ +#define memclr_(buffer, size) memset(buffer, 0, size) + +//------------- Conversion -------------// +/// form an uint32_t from 4 x uint8_t +static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) +{ + return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4; +} + +static inline uint8_t u16_high_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE; +static inline uint8_t u16_high_u8(uint16_t u16) +{ + return (uint8_t) ((u16 >> 8) & 0x00ff); +} + +static inline uint8_t u16_low_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE; +static inline uint8_t u16_low_u8(uint16_t u16) +{ + return (uint8_t) (u16 & 0x00ff); +} + +//------------- Min -------------// +static inline uint8_t min8_of(uint8_t x, uint8_t y) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint8_t min8_of(uint8_t x, uint8_t y) +{ + return (x < y) ? x : y; +} + +static inline uint16_t min16_of(uint16_t x, uint16_t y) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint16_t min16_of(uint16_t x, uint16_t y) +{ + return (x < y) ? x : y; +} + +static inline uint32_t min32_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t min32_of(uint32_t x, uint32_t y) +{ + return (x < y) ? x : y; +} + +//------------- Max -------------// +static inline uint32_t max32_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t max32_of(uint32_t x, uint32_t y) +{ + return (x > y) ? x : y; +} + +//------------- Align -------------// +static inline uint32_t align32 (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t align32 (uint32_t value) +{ + return (value & 0xFFFFFFE0UL); +} + +static inline uint32_t align16 (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t align16 (uint32_t value) +{ + return (value & 0xFFFFFFF0UL); +} + +static inline uint32_t align_n (uint32_t alignment, uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t align_n (uint32_t alignment, uint32_t value) +{ + return value & (~(alignment-1)); +} + +static inline uint32_t align4k (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t align4k (uint32_t value) +{ + return (value & 0xFFFFF000UL); +} + +static inline uint32_t offset4k(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint32_t offset4k(uint32_t value) +{ + return (value & 0xFFFUL); +} + +//------------- Mathematics -------------// +/// inclusive range checking +static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) +{ + return (lower <= value) && (value <= upper); +} + +/// exclusive range checking +static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper) +{ + return (lower < value) && (value < upper); +} + +static inline uint8_t log2_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint8_t log2_of(uint32_t value) +{ + uint8_t result = 0; // log2 of a value is its MSB's position + + while (value >>= 1) + { + result++; + } + return result; +} + +// return the number of set bits in value +static inline uint8_t cardinality_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST; +static inline uint8_t cardinality_of(uint32_t value) +{ + // Brian Kernighan's method goes through as many iterations as there are set bits. So if we have a 32-bit word with only + // the high bit set, then it will only go once through the loop + // Published in 1988, the C Programming Language 2nd Ed. (by Brian W. Kernighan and Dennis M. Ritchie) + // mentions this in exercise 2-9. On April 19, 2006 Don Knuth pointed out to me that this method + // "was first published by Peter Wegner in CACM 3 (1960), 322. (Also discovered independently by Derrick Lehmer and + // published in 1964 in a book edited by Beckenbach.)" + uint8_t count; + for (count = 0; value; count++) + { + value &= value - 1; // clear the least significant bit set + } + + return count; +} + +#ifdef __cplusplus + } +#endif + +#endif /* _COMMON_H_ */ + +/** @} */ +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/compiler.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/compiler.h new file mode 100644 index 0000000000..3096cd8079 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/common/compiler.h @@ -0,0 +1,152 @@ +/**************************************************************************/ +/*! + @file compiler.h + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, K. Townsend (microBuilder.eu) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/**************************************************************************/ + +/** \file + * \brief GCC Header + */ + +/** \ingroup Group_Compiler + * \defgroup Group_GCC GNU GCC + * @{ + */ + +#ifndef _COMPILER_GCC_H_ +#define _COMPILER_GCC_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#include "projectconfig.h" + +//#ifndef __GNUC__ +// #define ATTR_ALWAYS_INLINE +// #define ATTR_CONST +//#else + +#ifdef _TEST_ + #define ATTR_ALWAYS_INLINE + #define STATIC_ + #define INLINE_ +#else + #define STATIC_ static + #define INLINE_ inline + + #if CFG_DEBUG == 3 + #define ATTR_ALWAYS_INLINE // no inline for debug = 3 + #endif +#endif + +#define ALIGN_OF(x) __alignof__(x) + +/// Normally, the compiler places the objects it generates in sections like data or bss & function in text. Sometimes, however, you need additional sections, or you need certain particular variables to appear in special sections, for example to map to special hardware. The section attribute specifies that a variable (or function) lives in a particular section +#define ATTR_SECTION(section) __attribute__ ((#section)) + +/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, an error that includes message is diagnosed. This is useful for compile-time checking +#define ATTR_ERROR(Message) __attribute__ ((error(Message))) + +/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, a warning that includes message is diagnosed. This is useful for compile-time checking +#define ATTR_WARNING(Message) __attribute__ ((warning(Message))) + +/** + * \defgroup Group_VariableAttr Variable Attributes + * @{ + */ + +/// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes +#define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes))) + +/// The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute +#define ATTR_PACKED __attribute__ ((packed)) + +#define ATTR_PREPACKED + +#define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed)) +/** @} */ + +/** + * \defgroup Group_FuncAttr Function Attributes + * @{ + */ + +#ifndef ATTR_ALWAYS_INLINE +/// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified +#define ATTR_ALWAYS_INLINE __attribute__ ((always_inline)) +#endif + +/// The nonnull attribute specifies that some function parameters should be non-null pointers. f the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. All pointer arguments are marked as non-null +#define ATTR_NON_NULL __attribute__ ((nonull)) + +/// Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure +#define ATTR_PURE __attribute__ ((pure)) + +/// Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the pure attribute below, since function is not allowed to read global memory. +/// Note that a function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. It does not make sense for a const function to return void +#define ATTR_CONST __attribute__ ((const)) + +/// The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead. Note that the warnings only occurs for uses +#define ATTR_DEPRECATED __attribute__ ((deprecated)) + +/// Same as the deprecated attribute with optional message in the warning +#define ATTR_DEPRECATED_MESS(mess) __attribute__ ((deprecated(mess))) + +/// The weak attribute causes the declaration to be emitted as a weak symbol rather than a global. This is primarily useful in defining library functions that can be overridden in user code +#define ATTR_WEAK __attribute__ ((weak)) + +/// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified +#define ATTR_ALIAS(func) __attribute__ ((alias(#func))) + +/// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static +#define ATTR_WEAKREF(func) __attribute__ ((weakref(#func))) + +/// The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug +#define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) + +/// This attribute, attached to a function, means that code must be emitted for the function even if it appears that the function is not referenced. This is useful, for example, when the function is referenced only in inline assembly. +#define ATTR_USED __attribute__ ((used)) + +/// This attribute, attached to a function, means that the function is meant to be possibly unused. GCC does not produce a warning for this function. +#define ATTR_UNUSED __attribute__ ((unused)) + +/** @} */ + +#ifdef __cplusplus + } +#endif + +#endif /* _COMPILER_GCC_H_ */ + +/// @} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51822n.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51822n.cpp new file mode 100644 index 0000000000..0d005f03c3 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51822n.cpp @@ -0,0 +1,89 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + +#include "mbed.h" +#include "nRF51822n.h" + +#include "btle/btle.h" + +/**************************************************************************/ +/*! + @brief Constructor +*/ +/**************************************************************************/ +nRF51822n::nRF51822n(void) +{ +} + +/**************************************************************************/ +/*! + @brief Destructor +*/ +/**************************************************************************/ +nRF51822n::~nRF51822n(void) +{ +} + +/**************************************************************************/ +/*! + @brief Initialises anything required to start using BLE + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51822n::init(void) +{ + /* ToDo: Clear memory contents, reset the SD, etc. */ + btle_init(); + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Resets the BLE HW, removing any existing services and + characteristics + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51822n::reset(void) +{ + wait(0.5); + + /* Wait for the radio to come back up */ + wait(1); + + return BLE_ERROR_NONE; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51822n.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51822n.h new file mode 100644 index 0000000000..7b000c79e4 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51822n.h @@ -0,0 +1,49 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __NRF51822_H__ +#define __NRF51822_H__ + +#define NRF51 +#define DEBUG_NRF_USER +#define BLE_STACK_SUPPORT_REQD +#define BOARD_PCA10001 + +#include "mbed.h" +#include "blecommon.h" +#include "hw/BLEDevice.h" +#include "hw/nRF51822n/nRF51Gap.h" +#include "hw/nRF51822n/nRF51GattServer.h" + +/**************************************************************************/ +/*! + \brief + +*/ +/**************************************************************************/ +class nRF51822n : public BLEDevice +{ + public: + nRF51822n(void); + virtual ~nRF51822n(void); + + virtual Gap& getGap() { return nRF51Gap::getInstance(); }; + virtual GattServer& getGattServer() { return nRF51GattServer::getInstance(); }; + virtual ble_error_t init(void); + virtual ble_error_t reset(void); +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51Gap.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51Gap.cpp new file mode 100644 index 0000000000..6fd923b901 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51Gap.cpp @@ -0,0 +1,234 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + +#include "nRF51Gap.h" +#include "mbed.h" + +#include "common/common.h" +#include "ble_advdata.h" + +/**************************************************************************/ +/*! + @brief Sets the advertising parameters and payload for the device + + @param[in] params + Basic advertising details, including the advertising + delay, timeout and how the device should be advertised + @params[in] advData + The primary advertising data payload + @params[in] scanResponse + The optional Scan Response payload if the advertising + type is set to \ref GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED + in \ref GapAdveritinngParams + + @returns \ref ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @retval BLE_ERROR_BUFFER_OVERFLOW + The proposed action would cause a buffer overflow. All + advertising payloads must be <= 31 bytes, for example. + + @retval BLE_ERROR_NOT_IMPLEMENTED + A feature was requested that is not yet supported in the + nRF51 firmware or hardware. + + @retval BLE_ERROR_PARAM_OUT_OF_RANGE + One of the proposed values is outside the valid range. + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51Gap::setAdvertisingData(GapAdvertisingData & advData, GapAdvertisingData & scanResponse) +{ + /* Make sure we don't exceed the advertising payload length */ + if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD) + { + return BLE_ERROR_BUFFER_OVERFLOW; + } + + /* Make sure we have a payload! */ + if (advData.getPayloadLen() == 0) + { + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } + + /* Check the scan response payload limits */ + //if ((params.getAdvertisingType() == GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED)) + //{ + // /* Check if we're within the upper limit */ + // if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD) + // { + // return BLE_ERROR_BUFFER_OVERFLOW; + // } + // /* Make sure we have a payload! */ + // if (advData.getPayloadLen() == 0) + // { + // return BLE_ERROR_PARAM_OUT_OF_RANGE; + // } + //} + + /* Send advertising data! */ + ASSERT( ERROR_NONE == sd_ble_gap_adv_data_set(advData.getPayload(), advData.getPayloadLen(), + scanResponse.getPayload(), scanResponse.getPayloadLen()), BLE_ERROR_PARAM_OUT_OF_RANGE); + + /* Make sure the GAP Service appearance value is aligned with the appearance from GapAdvertisingData */ + ASSERT( ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()), BLE_ERROR_PARAM_OUT_OF_RANGE); + + /* ToDo: Perform some checks on the payload, for example the Scan Response can't */ + /* contains a flags AD type, etc. */ + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Starts the BLE HW, initialising any services that were + added before this function was called. + + @note All services must be added before calling this function! + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51Gap::startAdvertising(GapAdvertisingParams & params) +{ + /* Make sure we support the advertising type */ + if (params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) + { + /* ToDo: This requires a propery security implementation, etc. */ + return BLE_ERROR_NOT_IMPLEMENTED; + } + + /* Check interval range */ + if (params.getAdvertisingType() == GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED) + { + /* Min delay is slightly longer for unconnectable devices */ + if ((params.getInterval() < GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) || + (params.getInterval() > GAP_ADV_PARAMS_INTERVAL_MAX)) + { + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } + } + else + { + if ((params.getInterval() < GAP_ADV_PARAMS_INTERVAL_MIN) || + (params.getInterval() > GAP_ADV_PARAMS_INTERVAL_MAX)) + { + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } + } + + /* Check timeout is zero for Connectable Directed */ + if ((params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) && + (params.getTimeout() != 0)) + { + /* Timeout must be 0 with this type, although we'll never get here */ + /* since this isn't implemented yet anyway */ + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } + + /* Check timeout for other advertising types */ + if ((params.getAdvertisingType() != GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) && + (params.getTimeout() > GAP_ADV_PARAMS_TIMEOUT_MAX)) + { + return BLE_ERROR_PARAM_OUT_OF_RANGE; + } + + /* ToDo: Start Advertising */ + ble_gap_adv_params_t adv_para = { 0 }; + + adv_para.type = params.getAdvertisingType() ; + adv_para.p_peer_addr = NULL ; // Undirected advertisement + adv_para.fp = BLE_GAP_ADV_FP_ANY ; + adv_para.p_whitelist = NULL ; + adv_para.interval = params.getInterval() ; // advertising interval (in units of 0.625 ms) + adv_para.timeout = params.getTimeout() ; + + ASSERT( ERROR_NONE == sd_ble_gap_adv_start(&adv_para), BLE_ERROR_PARAM_OUT_OF_RANGE); + + state.advertising = 1; + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Stops the BLE HW and disconnects from any devices + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51Gap::stopAdvertising(void) +{ + /* ToDo: Stop Advertising */ + + /* ToDo: Check response */ + wait(0.1); + + state.advertising = 0; + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Disconnects if we are connected to a central device + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51Gap::disconnect(void) +{ + /* ToDo: Disconnect if we are connected to a central device */ + + state.advertising = 0; + state.connected = 0; + + return BLE_ERROR_NONE; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51Gap.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51Gap.h new file mode 100644 index 0000000000..15f32cacd9 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51Gap.h @@ -0,0 +1,53 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 __NRF51822_GAP_H__ +#define __NRF51822_GAP_H__ + +#include "mbed.h" +#include "blecommon.h" +#include "GapAdvertisingParams.h" +#include "GapAdvertisingData.h" +#include "hw/Gap.h" + +/**************************************************************************/ +/*! + \brief + +*/ +/**************************************************************************/ +class nRF51Gap : public Gap +{ + public: + static nRF51Gap& getInstance() + { + static nRF51Gap m_instance; + return m_instance; + } + + /* Functions that must be implemented from Gap */ + virtual ble_error_t setAdvertisingData(GapAdvertisingData &, GapAdvertisingData &); + virtual ble_error_t startAdvertising(GapAdvertisingParams &); + virtual ble_error_t stopAdvertising(void); + virtual ble_error_t disconnect(void); + + private: + nRF51Gap() { }; + nRF51Gap(nRF51Gap const&); + void operator=(nRF51Gap const&); +}; + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51GattServer.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51GattServer.cpp new file mode 100644 index 0000000000..021bf88d73 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nRF51GattServer.cpp @@ -0,0 +1,231 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + +#include "nRF51GattServer.h" +#include "mbed.h" + +#include "common/common.h" +#include "btle/custom/custom_helper.h" + +/**************************************************************************/ +/*! + @brief Adds a new service to the GATT table on the peripheral + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51GattServer::addService(GattService & service) +{ + /* ToDo: Make sure we don't overflow the array, etc. */ + /* ToDo: Make sure this service UUID doesn't already exist (?) */ + /* ToDo: Basic validation */ + + /* Add the service to the nRF51 */ + ble_uuid_t uuid; + + if (service.primaryServiceID.type == UUID::UUID_TYPE_SHORT) + { + /* 16-bit BLE UUID */ + uuid.type = BLE_UUID_TYPE_BLE; + } + else + { + /* 128-bit Custom UUID */ + uuid.type = custom_add_uuid_base( service.primaryServiceID.base ); + } + + uuid.uuid = service.primaryServiceID.value; + + ASSERT( ERROR_NONE == sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &uuid, &service.handle), BLE_ERROR_PARAM_OUT_OF_RANGE ); + + /* Add characteristics to the service */ + for (uint8_t i = 0; i < service.characteristicCount; i++) + { + GattCharacteristic * p_char = service.characteristics[i]; + + uuid.uuid = p_char->uuid; + ASSERT ( ERROR_NONE == custom_add_in_characteristic(service.handle, &uuid, p_char->properties, + NULL, p_char->lenMin, p_char->lenMax, &nrfCharacteristicHandles[characteristicCount]), BLE_ERROR_PARAM_OUT_OF_RANGE ); + + /* Update the characteristic handle */ + p_char->handle = characteristicCount; + p_characteristics[characteristicCount++] = p_char; + } + + serviceCount++; + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Reads the value of a characteristic, based on the service + and characteristic index fields + + @param[in] charHandle + The handle of the GattCharacteristic to read from + @param[in] buffer + Buffer to hold the the characteristic's value + (raw byte array in LSB format) + @param[in] len + The number of bytes read into the buffer + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51GattServer::readValue(uint16_t charHandle, uint8_t buffer[], uint16_t len) +{ + ASSERT( ERROR_NONE == sd_ble_gatts_value_get(nrfCharacteristicHandles[charHandle].value_handle, 0, &len, buffer), BLE_ERROR_PARAM_OUT_OF_RANGE); + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Updates the value of a characteristic, based on the service + and characteristic index fields + + @param[in] charHandle + The handle of the GattCharacteristic to write to + @param[in] buffer + Data to use when updating the characteristic's value + (raw byte array in LSB format) + @param[in] len + The number of bytes in buffer + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @section EXAMPLE + + @code + + @endcode +*/ +/**************************************************************************/ +ble_error_t nRF51GattServer::updateValue(uint16_t charHandle, uint8_t buffer[], uint16_t len) +{ + if ((p_characteristics[charHandle]->properties & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)) && + (m_connectionHandle != BLE_CONN_HANDLE_INVALID) ) + { + /* HVX update for the characteristic value */ + ble_gatts_hvx_params_t hvx_params; + + hvx_params.handle = nrfCharacteristicHandles[charHandle].value_handle; + hvx_params.type = (p_characteristics[charHandle]->properties & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) ? BLE_GATT_HVX_NOTIFICATION : BLE_GATT_HVX_INDICATION; + hvx_params.offset = 0; + hvx_params.p_data = buffer; + hvx_params.p_len = &len; + + error_t error = (error_t) sd_ble_gatts_hvx(m_connectionHandle, &hvx_params); + + /* ERROR_INVALID_STATE, ERROR_BUSY, ERROR_GATTS_SYS_ATTR_MISSING and ERROR_NO_TX_BUFFERS the ATT table has been updated. */ + if ( (error != ERROR_NONE ) && (error != ERROR_INVALID_STATE) && + (error != ERROR_BLE_NO_TX_BUFFERS ) && (error != ERROR_BUSY ) && + (error != ERROR_BLEGATTS_SYS_ATTR_MISSING ) ) + { + ASSERT_INT( ERROR_NONE, sd_ble_gatts_value_set(nrfCharacteristicHandles[charHandle].value_handle, 0, &len, buffer), BLE_ERROR_PARAM_OUT_OF_RANGE ); + } + } else + { + ASSERT_INT( ERROR_NONE, sd_ble_gatts_value_set(nrfCharacteristicHandles[charHandle].value_handle, 0, &len, buffer), BLE_ERROR_PARAM_OUT_OF_RANGE ); + } + + return BLE_ERROR_NONE; +} + +/**************************************************************************/ +/*! + @brief Callback handler for events getting pushed up from the SD +*/ +/**************************************************************************/ +void nRF51GattServer::hwCallback(ble_evt_t * p_ble_evt) +{ + uint16_t handle_value; + GattServerEvents::gattEvent_t event; + + switch (p_ble_evt->header.evt_id) + { + case BLE_GATTS_EVT_WRITE: + /* There are 2 use case here: Values being updated & CCCD (indicate/notify) enabled */ + + /* 1.) Handle CCCD changes */ + handle_value = p_ble_evt->evt.gatts_evt.params.write.handle; + for(uint8_t i=0; iproperties & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)) && + (nrfCharacteristicHandles[i].cccd_handle == handle_value) ) + { + uint16_t cccd_value = (p_ble_evt->evt.gatts_evt.params.write.data[1] << 8) | p_ble_evt->evt.gatts_evt.params.write.data[0]; /* Little Endian but M0 may be mis-aligned */ + + if ( ((p_characteristics[i]->properties & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE) && (cccd_value & BLE_GATT_HVX_INDICATION )) || + ((p_characteristics[i]->properties & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY ) && (cccd_value & BLE_GATT_HVX_NOTIFICATION))) + { + event = GattServerEvents::GATT_EVENT_UPDATES_ENABLED; + } else + { + event = GattServerEvents::GATT_EVENT_UPDATES_DISABLED; + } + + handleEvent(event, i); + return; + } + } + + /* 2.) Changes to the characteristic value will be handled with other events below */ + event = GattServerEvents::GATT_EVENT_DATA_WRITTEN; + break; + + case BLE_GATTS_EVT_HVC: + /* Indication confirmation received */ + event = GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED; + handle_value = p_ble_evt->evt.gatts_evt.params.hvc.handle; + break; + + default: + return; + } + + /* Find index (charHandle) in the pool */ + for(uint8_t i=0; i +#include "nrf51.h" +#include "nrf51_bitfields.h" +#include "nrf_soc.h" +#include "app_error.h" +//#include "nrf_delay.h" +#include "mbed.h" +#include "app_util.h" + + +#define RTC1_IRQ_PRI APP_IRQ_PRIORITY_LOW /**< Priority of the RTC1 interrupt (used for checking for timeouts and executing timeout handlers). */ +#define SWI0_IRQ_PRI APP_IRQ_PRIORITY_LOW /**< Priority of the SWI0 interrupt (used for updating the timer list). */ + +// The current design assumes that both interrupt handlers run at the same interrupt level. +// If this is to be changed, protection must be added to prevent them from interrupting each other +// (e.g. by using guard/trigger flags). +STATIC_ASSERT(RTC1_IRQ_PRI == SWI0_IRQ_PRI); + +#define MAX_RTC_COUNTER_VAL 0x00FFFFFF /**< Maximum value of the RTC counter. */ + +#define APP_HIGH_USER_ID 0 /**< User Id for the Application High "user". */ +#define APP_LOW_USER_ID 1 /**< User Id for the Application Low "user". */ +#define THREAD_MODE_USER_ID 2 /**< User Id for the Thread Mode "user". */ + +#define RTC_COMPARE_OFFSET_MIN 3 /**< Minimum offset between the current RTC counter value and the Capture Compare register. Although the nRF51 Series User Specification recommends this value to be 2, we use 3 to be safer.*/ + +#define MAX_RTC_TASKS_DELAY 47 /**< Maximum delay until an RTC task is executed. */ + +/**@brief Timer allocation state type. */ +typedef enum +{ + STATE_FREE, /**< The timer node is available. */ + STATE_ALLOCATED /**< The timer node has been allocated. */ +} timer_alloc_state_t; + +/**@brief Timer node type. The nodes will be used form a linked list of running timers. */ +typedef struct +{ + timer_alloc_state_t state; /**< Timer allocation state. */ + app_timer_mode_t mode; /**< Timer mode. */ + uint32_t ticks_to_expire; /**< Number of ticks from previous timer interrupt to timer expiry. */ + uint32_t ticks_at_start; /**< Current RTC counter value when the timer was started. */ + uint32_t ticks_first_interval; /**< Number of ticks in the first timer interval. */ + uint32_t ticks_periodic_interval; /**< Timer period (for repeating timers). */ + bool is_running; /**< True if timer is running, False otherwise. */ + app_timer_timeout_handler_t p_timeout_handler; /**< Pointer to function to be executed when the timer expires. */ + void * p_context; /**< General purpose pointer. Will be passed to the timeout handler when the timer expires. */ + app_timer_id_t next; /**< Id of next timer in list of running timers. */ +} timer_node_t; + +STATIC_ASSERT(sizeof(timer_node_t) <= APP_TIMER_NODE_SIZE); +STATIC_ASSERT(sizeof(timer_node_t) % 4 == 0); + +/**@brief Set of available timer operation types. */ +typedef enum +{ + TIMER_USER_OP_TYPE_NONE, /**< Invalid timer operation type. */ + TIMER_USER_OP_TYPE_START, /**< Timer operation type Start. */ + TIMER_USER_OP_TYPE_STOP, /**< Timer operation type Stop. */ + TIMER_USER_OP_TYPE_STOP_ALL /**< Timer operation type Stop All. */ +} timer_user_op_type_t; + +/**@brief Structure describing a timer start operation. */ +typedef struct +{ + uint32_t ticks_at_start; /**< Current RTC counter value when the timer was started. */ + uint32_t ticks_first_interval; /**< Number of ticks in the first timer interval. */ + uint32_t ticks_periodic_interval; /**< Timer period (for repeating timers). */ + void * p_context; /**< General purpose pointer. Will be passed to the timeout handler when the timer expires. */ +} timer_user_op_start_t; + +/**@brief Structure describing a timer operation. */ +typedef struct +{ + timer_user_op_type_t op_type; /**< Timer operation type. */ + app_timer_id_t timer_id; /**< Id of timer on which the operation is to be performed. */ + union + { + timer_user_op_start_t start; /**< Structure describing a timer start operation. */ + } params; +} timer_user_op_t; + +STATIC_ASSERT(sizeof(timer_user_op_t) <= APP_TIMER_USER_OP_SIZE); +STATIC_ASSERT(sizeof(timer_user_op_t) % 4 == 0); + +/**@brief Structure describing a timer user. + * + * @details For each user of the timer module, there will be a timer operations queue. This queue + * will hold timer operations issued by this user until the timer interrupt handler + * processes these operations. For the current implementation, there will be one user for + * each interrupt level available to the application (APP_HIGH, APP_LOW and THREAD_MODE), + * but the module can easily be modified to e.g. have one queue per process when using an + * RTOS. The purpose of the queues is to be able to have a completely lockless timer + * implementation. + */ +typedef struct +{ + uint8_t first; /**< Index of first entry to have been inserted in the queue (i.e. the next entry to be executed). */ + uint8_t last; /**< Index of last entry to have been inserted in the queue. */ + uint8_t user_op_queue_size; /**< Queue size. */ + timer_user_op_t * p_user_op_queue; /**< Queue buffer. */ +} timer_user_t; + +STATIC_ASSERT(sizeof(timer_user_t) == APP_TIMER_USER_SIZE); +STATIC_ASSERT(sizeof(timer_user_t) % 4 == 0); + +/**@brief User id type. + * + * @details In the current implementation, this will automatically be generated from the current + * interrupt level. + */ +typedef uint32_t timer_user_id_t; + +#define TIMER_NULL ((app_timer_id_t)(0 - 1)) /**< Invalid timer id. */ +#define CONTEXT_QUEUE_SIZE_MAX (2) /**< Timer internal elapsed ticks queue size. */ + +static uint8_t m_node_array_size; /**< Size of timer node array. */ +static timer_node_t * mp_nodes = NULL; /**< Array of timer nodes. */ +static uint8_t m_user_array_size; /**< Size of timer user array. */ +static timer_user_t * mp_users; /**< Array of timer users. */ +static app_timer_id_t m_timer_id_head; /**< First timer in list of running timers. */ +static uint32_t m_ticks_latest; /**< Last known RTC counter value. */ +static uint32_t m_ticks_elapsed[CONTEXT_QUEUE_SIZE_MAX]; /**< Timer internal elapsed ticks queue. */ +static uint8_t m_ticks_elapsed_q_read_ind; /**< Timer internal elapsed ticks queue read index. */ +static uint8_t m_ticks_elapsed_q_write_ind; /**< Timer internal elapsed ticks queue write index. */ +static app_timer_evt_schedule_func_t m_evt_schedule_func; /**< Pointer to function for propagating timeout events to the scheduler. */ + + +/**@brief Function for initializing the RTC1 counter. + * + * @param[in] prescaler Value of the RTC1 PRESCALER register. Set to 0 for no prescaling. + */ +static void rtc1_init(uint32_t prescaler) +{ + NRF_RTC1->PRESCALER = prescaler; + NVIC_SetPriority(RTC1_IRQn, RTC1_IRQ_PRI); +} + + +/**@brief Function for starting the RTC1 timer. + */ +static void rtc1_start(void) +{ + NRF_RTC1->EVTENSET = RTC_EVTEN_COMPARE0_Msk; + NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk; + + NVIC_ClearPendingIRQ(RTC1_IRQn); + NVIC_EnableIRQ(RTC1_IRQn); + + NRF_RTC1->TASKS_START = 1; + wait(0.0000001 * MAX_RTC_TASKS_DELAY); +} + + +/**@brief Function for stopping the RTC1 timer. + */ +static void rtc1_stop(void) +{ + NVIC_DisableIRQ(RTC1_IRQn); + + NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk; + NRF_RTC1->INTENCLR = RTC_INTENSET_COMPARE0_Msk; + + NRF_RTC1->TASKS_STOP = 1; + wait(0.0000001 * MAX_RTC_TASKS_DELAY); +} + + +/**@brief Function for returning the current value of the RTC1 counter. + * + * @return Current value of the RTC1 counter. + */ +static __INLINE uint32_t rtc1_counter_get(void) +{ + return NRF_RTC1->COUNTER; +} + + +/**@brief Function for computing the difference between two RTC1 counter values. + * + * @return Number of ticks elapsed from ticks_old to ticks_now. + */ +static __INLINE uint32_t ticks_diff_get(uint32_t ticks_now, uint32_t ticks_old) +{ + return ((ticks_now - ticks_old) & MAX_RTC_COUNTER_VAL); +} + + +/**@brief Function for setting the RTC1 Capture Compare register 0, and enabling the corresponding + * event. + * + * @param[in] value New value of Capture Compare register 0. + */ +static __INLINE void rtc1_compare0_set(uint32_t value) +{ + NRF_RTC1->CC[0] = value; +} + + +/**@brief Function for inserting a timer in the timer list. + * + * @param[in] timer_id Id of timer to insert. + */ +static void timer_list_insert(app_timer_id_t timer_id) +{ + timer_node_t * p_timer = &mp_nodes[timer_id]; + + if (m_timer_id_head == TIMER_NULL) + { + m_timer_id_head = timer_id; + } + else + { + if (p_timer->ticks_to_expire <= mp_nodes[m_timer_id_head].ticks_to_expire) + { + mp_nodes[m_timer_id_head].ticks_to_expire -= p_timer->ticks_to_expire; + + p_timer->next = m_timer_id_head; + m_timer_id_head = timer_id; + } + else + { + app_timer_id_t previous; + app_timer_id_t current; + uint32_t ticks_to_expire; + + ticks_to_expire = p_timer->ticks_to_expire; + previous = m_timer_id_head; + current = m_timer_id_head; + + while ((current != TIMER_NULL) && (ticks_to_expire > mp_nodes[current].ticks_to_expire)) + { + ticks_to_expire -= mp_nodes[current].ticks_to_expire; + previous = current; + current = mp_nodes[current].next; + } + + if (current != TIMER_NULL) + { + mp_nodes[current].ticks_to_expire -= ticks_to_expire; + } + + p_timer->ticks_to_expire = ticks_to_expire; + p_timer->next = current; + mp_nodes[previous].next = timer_id; + } + } +} + + +/**@brief Function for removing a timer from the timer queue. + * + * @param[in] timer_id Id of timer to remove. + */ +static void timer_list_remove(app_timer_id_t timer_id) +{ + app_timer_id_t previous; + app_timer_id_t current; + uint32_t timeout; + + // Find the timer's position in timer list + previous = m_timer_id_head; + current = previous; + + while (current != TIMER_NULL) + { + if (current == timer_id) + { + break; + } + previous = current; + current = mp_nodes[current].next; + } + + // Timer not in active list + if (current == TIMER_NULL) + { + return; + } + + // Timer is the first in the list + if (previous == current) + { + m_timer_id_head = mp_nodes[m_timer_id_head].next; + } + + // Remaining timeout between next timeout + timeout = mp_nodes[current].ticks_to_expire; + + // Link previous timer with next of this timer, i.e. removing the timer from list + mp_nodes[previous].next = mp_nodes[current].next; + + // If this is not the last timer, increment the next timer by this timer timeout + current = mp_nodes[previous].next; + if (current != TIMER_NULL) + { + mp_nodes[current].ticks_to_expire += timeout; + } +} + + +/**@brief Function for scheduling a check for timeouts by generating a RTC1 interrupt. + */ +static void timer_timeouts_check_sched(void) +{ + NVIC_SetPendingIRQ(RTC1_IRQn); +} + + +/**@brief Function for scheduling a timer list update by generating a SWI0 interrupt. + */ +static void timer_list_handler_sched(void) +{ + NVIC_SetPendingIRQ(SWI0_IRQn); +} + + +/**@brief Function for executing an application timeout handler, either by calling it directly, or + * by passing an event to the @ref app_scheduler. + * + * @param[in] p_timer Pointer to expired timer. + */ +static void timeout_handler_exec(timer_node_t * p_timer) +{ + if (m_evt_schedule_func != NULL) + { + uint32_t err_code = m_evt_schedule_func(p_timer->p_timeout_handler, p_timer->p_context); + APP_ERROR_CHECK(err_code); + } + else + { + p_timer->p_timeout_handler(p_timer->p_context); + } +} + + +/**@brief Function for checking for expired timers. + */ +static void timer_timeouts_check(void) +{ + // Handle expired of timer + if (m_timer_id_head != TIMER_NULL) + { + app_timer_id_t timer_id; + uint32_t ticks_elapsed; + uint32_t ticks_expired; + + // Initialize actual elapsed ticks being consumed to 0 + ticks_expired = 0; + + // ticks_elapsed is collected here, job will use it + ticks_elapsed = ticks_diff_get(rtc1_counter_get(), m_ticks_latest); + + // Auto variable containing the head of timers expiring + timer_id = m_timer_id_head; + + // Expire all timers within ticks_elapsed and collect ticks_expired + while (timer_id != TIMER_NULL) + { + timer_node_t * p_timer; + + // Auto variable for current timer node + p_timer = &mp_nodes[timer_id]; + + // Do nothing if timer did not expire + if (ticks_elapsed < p_timer->ticks_to_expire) + { + break; + } + + // Decrement ticks_elapsed and collect expired ticks + ticks_elapsed -= p_timer->ticks_to_expire; + ticks_expired += p_timer->ticks_to_expire; + + // Move to next timer + timer_id = p_timer->next; + + // Execute Task + timeout_handler_exec(p_timer); + } + + // Prepare to queue the ticks expired in the m_ticks_elapsed queue. + if (m_ticks_elapsed_q_read_ind == m_ticks_elapsed_q_write_ind) + { + // The read index of the queue is equal to the write index. This means the new + // value of ticks_expired should be stored at a new location in the m_ticks_elapsed + // queue (which is implemented as a double buffer). + + // Check if there will be a queue overflow. + if (++m_ticks_elapsed_q_write_ind == CONTEXT_QUEUE_SIZE_MAX) + { + // There will be a queue overflow. Hence the write index should point to the start + // of the queue. + m_ticks_elapsed_q_write_ind = 0; + } + } + + // Queue the ticks expired. + m_ticks_elapsed[m_ticks_elapsed_q_write_ind] = ticks_expired; + + timer_list_handler_sched(); + } +} + + +/**@brief Function for acquiring the number of ticks elapsed. + * + * @param[out] p_ticks_elapsed Number of ticks elapsed. + * + * @return TRUE if elapsed ticks was read from queue, FALSE otherwise. + */ +static bool elapsed_ticks_acquire(uint32_t * p_ticks_elapsed) +{ + // Pick the elapsed value from queue + if (m_ticks_elapsed_q_read_ind != m_ticks_elapsed_q_write_ind) + { + // Dequeue elapsed value + m_ticks_elapsed_q_read_ind++; + if (m_ticks_elapsed_q_read_ind == CONTEXT_QUEUE_SIZE_MAX) + { + m_ticks_elapsed_q_read_ind = 0; + } + + *p_ticks_elapsed = m_ticks_elapsed[m_ticks_elapsed_q_read_ind]; + + m_ticks_latest += *p_ticks_elapsed; + m_ticks_latest &= MAX_RTC_COUNTER_VAL; + + return true; + } + else + { + // No elapsed value in queue + *p_ticks_elapsed = 0; + return false; + } +} + + +/**@brief Function for handling the timer list deletions. + * + * @return TRUE if Capture Compare register must be updated, FALSE otherwise. + */ +static bool list_deletions_handler(void) +{ + app_timer_id_t timer_id_old_head; + uint8_t user_id; + + // Remember the old head, so as to decide if new compare needs to be set + timer_id_old_head = m_timer_id_head; + + user_id = m_user_array_size; + while (user_id--) + { + timer_user_t * p_user = &mp_users[user_id]; + uint8_t user_ops_first = p_user->first; + + while (user_ops_first != p_user->last) + { + timer_node_t * p_timer; + timer_user_op_t * p_user_op = &p_user->p_user_op_queue[user_ops_first]; + + // Traverse to next operation in queue + user_ops_first++; + if (user_ops_first == p_user->user_op_queue_size) + { + user_ops_first = 0; + } + + switch (p_user_op->op_type) + { + case TIMER_USER_OP_TYPE_STOP: + // Delete node if timer is running + p_timer = &mp_nodes[p_user_op->timer_id]; + if (p_timer->is_running) + { + timer_list_remove(p_user_op->timer_id); + p_timer->is_running = false; + } + break; + + case TIMER_USER_OP_TYPE_STOP_ALL: + // Delete list of running timers, and mark all timers as not running + while (m_timer_id_head != TIMER_NULL) + { + timer_node_t * p_head = &mp_nodes[m_timer_id_head]; + + p_head->is_running = false; + m_timer_id_head = p_head->next; + } + break; + + default: + // No implementation needed. + break; + } + } + } + + // Detect change in head of the list + return (m_timer_id_head != timer_id_old_head); +} + + +/**@brief Function for updating the timer list for expired timers. + * + * @param[in] ticks_elapsed Number of elapsed ticks. + * @param[in] ticks_previous Previous known value of the RTC counter. + * @param[out] p_restart_list_head List of repeating timers to be restarted. + */ +static void expired_timers_handler(uint32_t ticks_elapsed, + uint32_t ticks_previous, + app_timer_id_t * p_restart_list_head) +{ + uint32_t ticks_expired = 0; + + while (m_timer_id_head != TIMER_NULL) + { + timer_node_t * p_timer; + app_timer_id_t id_expired; + + // Auto variable for current timer node + p_timer = &mp_nodes[m_timer_id_head]; + + // Do nothing if timer did not expire + if (ticks_elapsed < p_timer->ticks_to_expire) + { + p_timer->ticks_to_expire -= ticks_elapsed; + break; + } + + // Decrement ticks_elapsed and collect expired ticks + ticks_elapsed -= p_timer->ticks_to_expire; + ticks_expired += p_timer->ticks_to_expire; + + // Timer expired, set ticks_to_expire zero + p_timer->ticks_to_expire = 0; + p_timer->is_running = false; + + // Remove the expired timer from head + id_expired = m_timer_id_head; + m_timer_id_head = p_timer->next; + + // Timer will be restarted if periodic + if (p_timer->ticks_periodic_interval != 0) + { + p_timer->ticks_at_start = (ticks_previous + ticks_expired) & MAX_RTC_COUNTER_VAL; + p_timer->ticks_first_interval = p_timer->ticks_periodic_interval; + p_timer->next = *p_restart_list_head; + *p_restart_list_head = id_expired; + } + } +} + + +/**@brief Function for handling timer list insertions. + * + * @param[in] p_restart_list_head List of repeating timers to be restarted. + * + * @return TRUE if Capture Compare register must be updated, FALSE otherwise. + */ +static bool list_insertions_handler(app_timer_id_t restart_list_head) +{ + app_timer_id_t timer_id_old_head; + uint8_t user_id; + + // Remember the old head, so as to decide if new compare needs to be set + timer_id_old_head = m_timer_id_head; + + user_id = m_user_array_size; + while (user_id--) + { + timer_user_t * p_user = &mp_users[user_id]; + + // Handle insertions of timers + while ((restart_list_head != TIMER_NULL) || (p_user->first != p_user->last)) + { + app_timer_id_t id_start; + timer_node_t * p_timer; + + if (restart_list_head != TIMER_NULL) + { + id_start = restart_list_head; + p_timer = &mp_nodes[id_start]; + restart_list_head = p_timer->next; + } + else + { + timer_user_op_t * p_user_op = &p_user->p_user_op_queue[p_user->first]; + + p_user->first++; + if (p_user->first == p_user->user_op_queue_size) + { + p_user->first = 0; + } + + id_start = p_user_op->timer_id; + p_timer = &mp_nodes[id_start]; + + if ((p_user_op->op_type != TIMER_USER_OP_TYPE_START) || p_timer->is_running) + { + continue; + } + + p_timer->ticks_at_start = p_user_op->params.start.ticks_at_start; + p_timer->ticks_first_interval = p_user_op->params.start.ticks_first_interval; + p_timer->ticks_periodic_interval = p_user_op->params.start.ticks_periodic_interval; + p_timer->p_context = p_user_op->params.start.p_context; + } + + // Prepare the node to be inserted + if ( + ((p_timer->ticks_at_start - m_ticks_latest) & MAX_RTC_COUNTER_VAL) + < + (MAX_RTC_COUNTER_VAL / 2) + ) + { + p_timer->ticks_to_expire = ticks_diff_get(p_timer->ticks_at_start, m_ticks_latest) + + p_timer->ticks_first_interval; + } + else + { + uint32_t delta_current_start; + + delta_current_start = ticks_diff_get(m_ticks_latest, p_timer->ticks_at_start); + if (p_timer->ticks_first_interval > delta_current_start) + { + p_timer->ticks_to_expire = p_timer->ticks_first_interval - delta_current_start; + } + else + { + p_timer->ticks_to_expire = 0; + } + } + + p_timer->ticks_at_start = 0; + p_timer->ticks_first_interval = 0; + p_timer->is_running = true; + p_timer->next = TIMER_NULL; + + // Insert into list + timer_list_insert(id_start); + } + } + + return (m_timer_id_head != timer_id_old_head); +} + + +/**@brief Function for updating the Capture Compare register. + */ +static void compare_reg_update(app_timer_id_t timer_id_head_old) +{ + // Setup the timeout for timers on the head of the list + if (m_timer_id_head != TIMER_NULL) + { + uint32_t ticks_to_expire = mp_nodes[m_timer_id_head].ticks_to_expire; + uint32_t pre_counter_val = rtc1_counter_get(); + uint32_t cc = m_ticks_latest; + uint32_t ticks_elapsed = ticks_diff_get(pre_counter_val, cc) + RTC_COMPARE_OFFSET_MIN; + + if (timer_id_head_old == TIMER_NULL) + { + // No timers were already running, start RTC + rtc1_start(); + } + + cc += (ticks_elapsed < ticks_to_expire) ? ticks_to_expire : ticks_elapsed; + cc &= MAX_RTC_COUNTER_VAL; + + rtc1_compare0_set(cc); + + uint32_t post_counter_val = rtc1_counter_get(); + + if ( + (ticks_diff_get(post_counter_val, pre_counter_val) + RTC_COMPARE_OFFSET_MIN) + > + ticks_diff_get(cc, pre_counter_val) + ) + { + // When this happens the COMPARE event may not be triggered by the RTC. + // The nRF51 Series User Specification states that if the COUNTER value is N + // (i.e post_counter_val = N), writing N or N+1 to a CC register may not trigger a + // COMPARE event. Hence the RTC interrupt is forcefully pended by calling the following + // function. + timer_timeouts_check_sched(); + } + } + else + { + // No timers are running, stop RTC + rtc1_stop(); + } +} + + +/**@brief Function for handling changes to the timer list. + */ +static void timer_list_handler(void) +{ + app_timer_id_t restart_list_head = TIMER_NULL; + uint32_t ticks_elapsed; + uint32_t ticks_previous; + bool ticks_have_elapsed; + bool compare_update; + app_timer_id_t timer_id_head_old; + + // Back up the previous known tick and previous list head + ticks_previous = m_ticks_latest; + timer_id_head_old = m_timer_id_head; + + // Get number of elapsed ticks + ticks_have_elapsed = elapsed_ticks_acquire(&ticks_elapsed); + + // Handle list deletions + compare_update = list_deletions_handler(); + + // Handle expired timers + if (ticks_have_elapsed) + { + expired_timers_handler(ticks_elapsed, ticks_previous, &restart_list_head); + compare_update = true; + } + + // Handle list insertions + if (list_insertions_handler(restart_list_head)) + { + compare_update = true; + } + + // Update compare register if necessary + if (compare_update) + { + compare_reg_update(timer_id_head_old); + } +} + + +/**@brief Function for enqueueing a new operations queue entry. + * + * @param[in] p_user User that the entry is to be enqueued for. + * @param[in] last_index Index of the next last index to be enqueued. + */ +static void user_op_enque(timer_user_t * p_user, app_timer_id_t last_index) +{ + p_user->last = last_index; +} + + +/**@brief Function for allocating a new operations queue entry. + * + * @param[in] p_user User that the entry is to be allocated for. + * @param[out] p_last_index Index of the next last index to be enqueued. + * + * @return Pointer to allocated queue entry, or NULL if queue is full. + */ +static timer_user_op_t * user_op_alloc(timer_user_t * p_user, app_timer_id_t * p_last_index) +{ + app_timer_id_t last; + timer_user_op_t * p_user_op; + + last = p_user->last + 1; + if (last == p_user->user_op_queue_size) + { + // Overflow case. + last = 0; + } + if (last == p_user->first) + { + // Queue is full. + return NULL; + } + + *p_last_index = last; + p_user_op = &p_user->p_user_op_queue[p_user->last]; + + return p_user_op; +} + + +/**@brief Function for scheduling a Timer Start operation. + * + * @param[in] user_id Id of user calling this function. + * @param[in] timer_id Id of timer to start. + * @param[in] timeout_initial Time (in ticks) to first timer expiry. + * @param[in] timeout_periodic Time (in ticks) between periodic expiries. + * @param[in] p_context General purpose pointer. Will be passed to the timeout handler when + * the timer expires. + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t timer_start_op_schedule(timer_user_id_t user_id, + app_timer_id_t timer_id, + uint32_t timeout_initial, + uint32_t timeout_periodic, + void * p_context) +{ + app_timer_id_t last_index; + + timer_user_op_t * p_user_op = user_op_alloc(&mp_users[user_id], &last_index); + if (p_user_op == NULL) + { + return NRF_ERROR_NO_MEM; + } + + p_user_op->op_type = TIMER_USER_OP_TYPE_START; + p_user_op->timer_id = timer_id; + p_user_op->params.start.ticks_at_start = rtc1_counter_get(); + p_user_op->params.start.ticks_first_interval = timeout_initial; + p_user_op->params.start.ticks_periodic_interval = timeout_periodic; + p_user_op->params.start.p_context = p_context; + + user_op_enque(&mp_users[user_id], last_index); + + timer_list_handler_sched(); + + return NRF_SUCCESS; +} + + +/**@brief Function for scheduling a Timer Stop operation. + * + * @param[in] user_id Id of user calling this function. + * @param[in] timer_id Id of timer to stop. + * + * @return NRF_SUCCESS on successful scheduling a timer stop operation. NRF_ERROR_NO_MEM when there + * is no memory left to schedule the timer stop operation. + */ +static uint32_t timer_stop_op_schedule(timer_user_id_t user_id, app_timer_id_t timer_id) +{ + app_timer_id_t last_index; + + timer_user_op_t * p_user_op = user_op_alloc(&mp_users[user_id], &last_index); + if (p_user_op == NULL) + { + return NRF_ERROR_NO_MEM; + } + + p_user_op->op_type = TIMER_USER_OP_TYPE_STOP; + p_user_op->timer_id = timer_id; + + user_op_enque(&mp_users[user_id], last_index); + + timer_list_handler_sched(); + + return NRF_SUCCESS; +} + + +/**@brief Function for scheduling a Timer Stop All operation. + * + * @param[in] user_id Id of user calling this function. + */ +static uint32_t timer_stop_all_op_schedule(timer_user_id_t user_id) +{ + app_timer_id_t last_index; + + timer_user_op_t * p_user_op = user_op_alloc(&mp_users[user_id], &last_index); + if (p_user_op == NULL) + { + return NRF_ERROR_NO_MEM; + } + + p_user_op->op_type = TIMER_USER_OP_TYPE_STOP_ALL; + p_user_op->timer_id = TIMER_NULL; + + user_op_enque(&mp_users[user_id], last_index); + + timer_list_handler_sched(); + + return NRF_SUCCESS; +} + + +/**@brief Function for handling the RTC1 interrupt. + * + * @details Checks for timeouts, and executes timeout handlers for expired timers. + */ +extern "C" void RTC1_IRQHandler(void) +{ + // Clear all events (also unexpected ones) + NRF_RTC1->EVENTS_COMPARE[0] = 0; + NRF_RTC1->EVENTS_COMPARE[1] = 0; + NRF_RTC1->EVENTS_COMPARE[2] = 0; + NRF_RTC1->EVENTS_COMPARE[3] = 0; + NRF_RTC1->EVENTS_TICK = 0; + NRF_RTC1->EVENTS_OVRFLW = 0; + + // Check for expired timers + timer_timeouts_check(); +} + +/**@brief Function for handling the SWI0 interrupt. + * + * @details Performs all updates to the timer list. + */ +extern "C" void SWI0_IRQHandler(void) +{ + timer_list_handler(); +} + +uint32_t app_timer_init(uint32_t prescaler, + uint8_t max_timers, + uint8_t op_queues_size, + void * p_buffer, + app_timer_evt_schedule_func_t evt_schedule_func) +{ + int i; + + // Check that buffer is correctly aligned + if (!is_word_aligned(p_buffer)) + { + return NRF_ERROR_INVALID_PARAM; + } + // Check for NULL buffer + if (p_buffer == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Stop RTC to prevent any running timers from expiring (in case of reinitialization) + rtc1_stop(); + + m_evt_schedule_func = evt_schedule_func; + + // Initialize timer node array + m_node_array_size = max_timers; + mp_nodes = (timer_node_t *) p_buffer; + + for (i = 0; i < max_timers; i++) + { + mp_nodes[i].state = STATE_FREE; + mp_nodes[i].is_running = false; + } + + // Skip timer node array + p_buffer = &((uint8_t *)p_buffer)[max_timers * sizeof(timer_node_t)]; + + // Initialize users array + m_user_array_size = APP_TIMER_INT_LEVELS; + mp_users = (timer_user_t *) p_buffer; + + // Skip user array + p_buffer = &((uint8_t *)p_buffer)[APP_TIMER_INT_LEVELS * sizeof(timer_user_t)]; + + // Initialize operation queues + for (i = 0; i < APP_TIMER_INT_LEVELS; i++) + { + timer_user_t * p_user = &mp_users[i]; + + p_user->first = 0; + p_user->last = 0; + p_user->user_op_queue_size = op_queues_size; + p_user->p_user_op_queue = (timer_user_op_t *) p_buffer; + + // Skip operation queue + p_buffer = &((uint8_t *)p_buffer)[op_queues_size * sizeof(timer_user_op_t)]; + } + + m_timer_id_head = TIMER_NULL; + m_ticks_elapsed_q_read_ind = 0; + m_ticks_elapsed_q_write_ind = 0; + + NVIC_ClearPendingIRQ(SWI0_IRQn); + NVIC_SetPriority(SWI0_IRQn, SWI0_IRQ_PRI); + NVIC_EnableIRQ(SWI0_IRQn); + + rtc1_init(prescaler); + + m_ticks_latest = rtc1_counter_get(); + + return NRF_SUCCESS; +} + + +uint32_t app_timer_create(app_timer_id_t * p_timer_id, + app_timer_mode_t mode, + app_timer_timeout_handler_t timeout_handler) +{ + int i; + + // Check state and parameters + if (mp_nodes == NULL) + { + return NRF_ERROR_INVALID_STATE; + } + if (timeout_handler == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + if (p_timer_id == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Find free timer + for (i = 0; i < m_node_array_size; i++) + { + if (mp_nodes[i].state == STATE_FREE) + { + mp_nodes[i].state = STATE_ALLOCATED; + mp_nodes[i].mode = mode; + mp_nodes[i].p_timeout_handler = timeout_handler; + + *p_timer_id = i; + return NRF_SUCCESS; + } + } + + return NRF_ERROR_NO_MEM; +} + + +/**@brief Function for creating a timer user id from the current interrupt level. + * + * @return Timer user id. +*/ +static timer_user_id_t user_id_get(void) +{ + timer_user_id_t ret; + + STATIC_ASSERT(APP_TIMER_INT_LEVELS == 3); + + switch (current_int_priority_get()) + { + case APP_IRQ_PRIORITY_HIGH: + ret = APP_HIGH_USER_ID; + break; + + case APP_IRQ_PRIORITY_LOW: + ret = APP_LOW_USER_ID; + break; + + default: + ret = THREAD_MODE_USER_ID; + break; + } + + return ret; +} + + +uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context) +{ + uint32_t timeout_periodic; + + // Check state and parameters + if (mp_nodes == NULL) + { + return NRF_ERROR_INVALID_STATE; + } + if ((timer_id >= m_node_array_size) || (timeout_ticks < APP_TIMER_MIN_TIMEOUT_TICKS)) + { + return NRF_ERROR_INVALID_PARAM; + } + if (mp_nodes[timer_id].state != STATE_ALLOCATED) + { + return NRF_ERROR_INVALID_STATE; + } + + // Schedule timer start operation + timeout_periodic = (mp_nodes[timer_id].mode == APP_TIMER_MODE_REPEATED) ? timeout_ticks : 0; + + return timer_start_op_schedule(user_id_get(), + timer_id, + timeout_ticks, + timeout_periodic, + p_context); +} + + +uint32_t app_timer_stop(app_timer_id_t timer_id) +{ + // Check state and parameters + if (mp_nodes == NULL) + { + return NRF_ERROR_INVALID_STATE; + } + if (timer_id >= m_node_array_size) + { + return NRF_ERROR_INVALID_PARAM; + } + if (mp_nodes[timer_id].state != STATE_ALLOCATED) + { + return NRF_ERROR_INVALID_STATE; + } + + // Schedule timer stop operation + return timer_stop_op_schedule(user_id_get(), timer_id); +} + + +uint32_t app_timer_stop_all(void) +{ + // Check state + if (mp_nodes == NULL) + { + return NRF_ERROR_INVALID_STATE; + } + + return timer_stop_all_op_schedule(user_id_get()); +} + + +uint32_t app_timer_cnt_get(uint32_t * p_ticks) +{ + *p_ticks = rtc1_counter_get(); + return NRF_SUCCESS; +} + + +uint32_t app_timer_cnt_diff_compute(uint32_t ticks_to, + uint32_t ticks_from, + uint32_t * p_ticks_diff) +{ + *p_ticks_diff = ticks_diff_get(ticks_to, ticks_from); + return NRF_SUCCESS; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/crc16.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/crc16.cpp new file mode 100644 index 0000000000..ec156f6993 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/crc16.cpp @@ -0,0 +1,31 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include "crc16.h" +#include + +uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc) +{ + uint32_t i; + uint16_t crc = (p_crc == NULL) ? 0xffff : *p_crc; + + for (i = 0; i < size; i++) + { + crc = (unsigned char)(crc >> 8) | (crc << 8); + crc ^= p_data[i]; + crc ^= (unsigned char)(crc & 0xff) >> 4; + crc ^= (crc << 8) << 4; + crc ^= ((crc & 0xff) << 4) << 1; + } + + return crc; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/pstorage.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/pstorage.cpp new file mode 100644 index 0000000000..e979918611 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/app_common/pstorage.cpp @@ -0,0 +1,759 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include +#include +#include +#include "nordic_common.h" +#include "nrf_error.h" +#include "nrf_assert.h" +//#include "nrf.h" +#include "nrf_soc.h" +#include "app_util.h" +#include "pstorage.h" + + +#define INVALID_OPCODE 0x00 /**< Invalid op code identifier. */ +#define SOC_MAX_WRITE_SIZE 1024 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API. */ + +/** + * @defgroup api_param_check API Parameters check macros. + * + * @details Macros that verify parameters passed to the module in the APIs. These macros + * could be mapped to nothing in final versions of code to save execution and size. + * + * @{ + */ +/** + * @brief Check if the input pointer is NULL, if it is returns NRF_ERROR_NULL. + */ +#define NULL_PARAM_CHECK(PARAM) \ + if ((PARAM) == NULL) \ + { \ + return NRF_ERROR_NULL; \ + } + +/** + * @brief Verifies the module identifier supplied by the application is within permissible + * range. + */ +#define MODULE_ID_RANGE_CHECK(ID) \ + if ((((ID)->module_id) >= PSTORAGE_MAX_APPLICATIONS) || \ + (m_app_table[(ID)->module_id].cb == NULL)) \ + { \ + return NRF_ERROR_INVALID_PARAM; \ + } + +/** + * @brief Verifies the block identifier supplied by the application is within the permissible + * range. + */ +#define BLOCK_ID_RANGE_CHECK(ID) \ + if (((ID)->block_id) >= (m_app_table[(ID)->module_id].base_id + \ + (m_app_table[(ID)->module_id].block_count * MODULE_BLOCK_SIZE(ID)))) \ + { \ + return NRF_ERROR_INVALID_PARAM; \ + } + + +/** + * @brief Verifies the block size requested by the application can be supported by the module. + */ +#define BLOCK_SIZE_CHECK(X) \ + if (((X) > PSTORAGE_MAX_BLOCK_SIZE) || ((X) < PSTORAGE_MIN_BLOCK_SIZE)) \ + { \ + return NRF_ERROR_INVALID_PARAM; \ + } + +/** + * @brief Verifies block size requested by Application in registration API. + */ +#define BLOCK_COUNT_CHECK(COUNT, SIZE) \ + if (((COUNT) == 0) || ((m_next_page_addr + ((COUNT) *(SIZE)) > PSTORAGE_DATA_END_ADDR))) \ + { \ + return NRF_ERROR_INVALID_PARAM; \ + } + +/** + * @brief Verifies size parameter provided by application in API. + */ +#define SIZE_CHECK(ID, SIZE) \ + if(((SIZE) == 0) || ((SIZE) > MODULE_BLOCK_SIZE(ID))) \ + { \ + return NRF_ERROR_INVALID_PARAM; \ + } + +/** + * @brief Verifies offset parameter provided by application in API. + */ +#define OFFSET_CHECK(ID, OFFSET, SIZE) \ + if(((SIZE) + (OFFSET)) > MODULE_BLOCK_SIZE(ID)) \ + { \ + return NRF_ERROR_INVALID_PARAM; \ + } + +#ifdef PSTORAGE_RAW_MODE_ENABLE + +/** + * @brief Verifies the module identifier supplied by the application is registered for raw mode. + */ +#define MODULE_RAW_ID_RANGE_CHECK(ID) \ + if ((PSTORAGE_MAX_APPLICATIONS+1 != ((ID)->module_id)) || \ + (m_raw_app_table.cb == NULL)) \ + { \ + return NRF_ERROR_INVALID_PARAM; \ + } + +#endif // PSTORAGE_RAW_MODE_ENABLE + +/**@} */ + +/**@brief Verify module's initialization status. + * + * @details Verify module's initialization status. Returns NRF_ERROR_INVALID_STATE in case a + * module API is called without initializing the module. + */ +#define VERIFY_MODULE_INITIALIZED() \ + do \ + { \ + if (!m_module_initialized) \ + { \ + return NRF_ERROR_INVALID_STATE; \ + } \ + } while(0) + +/**@brief Macro to fetch the block size registered for the module. */ +#define MODULE_BLOCK_SIZE(ID) (m_app_table[(ID)->module_id].block_size) + +/**@} */ + +/** + * @brief Application registration information. + * + * @details Define application specific information that application needs to maintain to be able + * to process requests from each one of them. + */ +typedef struct +{ + pstorage_ntf_cb_t cb; /**< Callback registered with the module to be notified of result of flash access. */ + pstorage_block_t base_id; /**< Base block id assigned to the module */ + pstorage_size_t block_size; /**< Size of block for the module */ + pstorage_size_t block_count; /**< Number of block requested by application */ + pstorage_size_t no_of_pages; /**< Variable to remember how many pages have been allocated for this module. This information is used for clearing of block, so that application does not need to have knowledge of number of pages its using. */ +} pstorage_module_table_t; + +#ifdef PSTORAGE_RAW_MODE_ENABLE +/** + * @brief Application registration information. + * + * @details Define application specific information that application registered for raw mode. + */ +typedef struct +{ + pstorage_ntf_cb_t cb; /**< Callback registered with the module to be notified of result of flash access. */ + uint16_t no_of_pages; /**< Variable to remember how many pages have been allocated for this module. This information is used for clearing of block, so that application does not need to have knowledge of number of pages its using. */ +} pstorage_raw_module_table_t; +#endif // PSTORAGE_RAW_MODE_ENABLE + + + + +/** + * @brief Defines command queue element. + * + * @details Defines command queue element. Each element encapsulates needed information to process + * a flash access command. + */ +typedef struct +{ + uint8_t op_code; /**< Identifies flash access operation being queued. Element is free is op-code is INVALID_OPCODE */ + pstorage_size_t size; /**< Identifies size in bytes requested for the operation. */ + pstorage_size_t offset; /**< Offset requested by the application for access operation. */ + pstorage_handle_t storage_addr; /**< Address/Identifier for persistent memory. */ + uint8_t * p_data_addr; /**< Address/Identifier for data memory. This is assumed to be resident memory. */ +} cmd_queue_element_t; + + +/** + * @brief Defines command queue, an element is free is op_code field is not invalid. + * + * @details Defines commands enqueued for flash access. At any point of time, this queue has one or + * more flash access operation pending if the count field is not zero. When the queue is + * not empty, the rp (read pointer) field points to the flash access command in progress + * or to requested next. The queue implements a simple first in first out algorithm. + * Data addresses are assumed to be resident. + */ +typedef struct +{ + uint8_t rp; /**< Read pointer, pointing to flash access that is ongoing or to be requested next. */ + uint8_t count; /**< Number of elements in the queue. */ + bool flash_access; /**< Flag to ensure an flash event received is for an request issued by the module. */ + cmd_queue_element_t cmd[PSTORAGE_CMD_QUEUE_SIZE]; /**< Array to maintain flash access operation details */ +}cmd_queue_t; + +static cmd_queue_t m_cmd_queue; /**< Flash operation request queue. */ +static pstorage_module_table_t m_app_table[PSTORAGE_MAX_APPLICATIONS]; /**< Registered application information table. */ + +#ifdef PSTORAGE_RAW_MODE_ENABLE +static pstorage_raw_module_table_t m_raw_app_table; /**< Registered application information table for raw mode. */ +#endif // PSTORAGE_RAW_MODE_ENABLE + +static pstorage_size_t m_next_app_instance; /**< Points to the application module instance that can be allocated next */ +static uint32_t m_next_page_addr; /**< Points to the flash address that can be allocated to a module next, this is needed as blocks of a module can span across flash pages. */ +static bool m_module_initialized = false; /**< Flag for checking if module has been initialized. */ +static pstorage_size_t m_round_val; /**< Round value for multiple round operations. For erase operations, the round value will contain current round counter which is identical to number of pages erased. For store operations, the round value contains current round of operation * SOC_MAX_WRITE_SIZE to ensure each store to the SoC Flash API is within the SoC limit. */ + +static uint32_t process_cmd(void); +static void app_notify (uint32_t reason); + +/** + * @defgroup utility_functions Utility internal functions. + * @{ + * @details Utility functions needed for interfacing with flash through SoC APIs. + * SoC APIs are non blocking and provide the result of flash access through an event. + * + * @note Only one flash access operation is permitted at a time by SoC. Hence a queue is + * maintained by this module. + */ + +/** + * @brief Initializes command queue element. + */ +static void cmd_queue_init_element(uint32_t index) +{ + // Internal function and checks on range of index can be avoided + m_cmd_queue.cmd[index].op_code = INVALID_OPCODE; + m_cmd_queue.cmd[index].size = 0; + m_cmd_queue.cmd[index].storage_addr.module_id = PSTORAGE_MAX_APPLICATIONS; + m_cmd_queue.cmd[index].storage_addr.block_id = 0; + m_cmd_queue.cmd[index].p_data_addr = NULL; + m_cmd_queue.cmd[index].offset = 0; +} + + +/** + * @brief Initializes command queue. + */ +static void cmd_queue_init (void) +{ + uint32_t cmd_index; + + m_round_val = 0; + m_cmd_queue.rp = 0; + m_cmd_queue.count = 0; + m_cmd_queue.flash_access = false; + + for(cmd_index = 0; cmd_index < PSTORAGE_CMD_QUEUE_SIZE; cmd_index++) + { + cmd_queue_init_element(cmd_index); + } +} + + +/** + * @brief Routine to enqueue a flash access operation. + */ +static uint32_t cmd_queue_enqueue(uint8_t opcode, pstorage_handle_t * p_storage_addr,uint8_t * p_data_addr, pstorage_size_t size, pstorage_size_t offset) +{ + uint32_t retval; + uint8_t write_index = 0; + retval = NRF_ERROR_NO_MEM; + + // Check if flash access is ongoing. + if ((m_cmd_queue.flash_access == false) && (m_cmd_queue.count == 0)) + { + m_cmd_queue.rp = 0; + m_cmd_queue.cmd[m_cmd_queue.rp].op_code = opcode; + m_cmd_queue.cmd[m_cmd_queue.rp].p_data_addr = p_data_addr; + m_cmd_queue.cmd[m_cmd_queue.rp].storage_addr = (*p_storage_addr); + m_cmd_queue.cmd[m_cmd_queue.rp].size = size; + m_cmd_queue.cmd[m_cmd_queue.rp].offset = offset; + m_cmd_queue.count++; + retval = process_cmd(); + if ((retval == NRF_SUCCESS) || (retval == NRF_ERROR_BUSY)) + { + // In case of busy error code, it is possible to attempt to access flash + retval = NRF_SUCCESS; + } + } + else if (m_cmd_queue.count != PSTORAGE_CMD_QUEUE_SIZE) + { + // Enqueue the command if it is queue is not full + write_index = m_cmd_queue.rp + m_cmd_queue.count; + + if (write_index >= PSTORAGE_CMD_QUEUE_SIZE) + { + write_index -= PSTORAGE_CMD_QUEUE_SIZE; + } + + m_cmd_queue.cmd[write_index].op_code = opcode; + m_cmd_queue.cmd[write_index].p_data_addr = p_data_addr; + m_cmd_queue.cmd[write_index].storage_addr = (*p_storage_addr); + m_cmd_queue.cmd[write_index].size = size; + m_cmd_queue.cmd[write_index].offset = offset; + m_cmd_queue.count++; + + retval = NRF_SUCCESS; + + } + + return retval; +} + + +/** + * @brief Dequeues a command element. + */ +static uint32_t cmd_queue_dequeue(void) +{ + uint32_t retval; + + cmd_queue_element_t * p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp]; + // Update count and read pointer to process any queued requests + if(m_round_val >= p_cmd->size) + { + // Initialize/free the element as it is now processed. + cmd_queue_init_element(m_cmd_queue.rp); + m_round_val = 0; + m_cmd_queue.count--; + m_cmd_queue.rp++; + } + + retval = NRF_SUCCESS; + + // If any flash operation is enqueued, schedule + if (m_cmd_queue.count) + { + retval = process_cmd(); + + if (retval != NRF_SUCCESS) + { + // Flash could be accessed by modules other than Bond Manager, hence a busy error is + // acceptable, but any other error needs to be indicated to the bond manager + if (retval != NRF_ERROR_BUSY) + { + app_notify (retval); + } + else + { + // In case of busy next trigger will be a success or a failure event + } + } + } + else + { + // No flash access request pending + } + + return retval; +} + + +/** + * @brief Routine to notify application of any errors. + */ +static void app_notify (uint32_t result) +{ + pstorage_ntf_cb_t ntf_cb; + uint8_t op_code = m_cmd_queue.cmd[m_cmd_queue.rp].op_code; + +#ifdef PSTORAGE_RAW_MODE_ENABLE + if(m_cmd_queue.cmd[m_cmd_queue.rp].storage_addr.module_id == (PSTORAGE_MAX_APPLICATIONS + 1)) + { + ntf_cb = m_raw_app_table.cb; + } + else +#endif // PSTORAGE_RAW_MODE_ENABLE + { + ntf_cb = m_app_table[m_cmd_queue.cmd[m_cmd_queue.rp].storage_addr.module_id].cb; + } + + // Indicate result to client. + // For PSTORAGE_CLEAR_OP_CODE no size is returned as the size field is used only internally + // for clients registering multiple pages. + ntf_cb(&m_cmd_queue.cmd[m_cmd_queue.rp].storage_addr, + op_code, + result, + m_cmd_queue.cmd[m_cmd_queue.rp].p_data_addr, + op_code == PSTORAGE_CLEAR_OP_CODE ? 0 : m_cmd_queue.cmd[m_cmd_queue.rp].size); +} + + +/** + * @brief Handles Flash Access Result Events. + */ +void pstorage_sys_event_handler (uint32_t sys_evt) +{ + uint32_t retval; + + retval = NRF_SUCCESS; + + // Its possible the flash access was not initiated by bond manager, hence + // event is processed only if the event triggered was for an operation requested by the + // bond manager. + if (m_cmd_queue.flash_access == true) + { + cmd_queue_element_t * p_cmd; + m_cmd_queue.flash_access = false; + switch (sys_evt) + { + case NRF_EVT_FLASH_OPERATION_SUCCESS: + p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp]; + if ((p_cmd->op_code != PSTORAGE_CLEAR_OP_CODE) || (m_round_val >= p_cmd->size)) + { + app_notify(retval); + } + // Schedule any queued flash access operations + retval = cmd_queue_dequeue (); + if (retval != NRF_SUCCESS) + { + app_notify(retval); + } + + break; + case NRF_EVT_FLASH_OPERATION_ERROR: + app_notify(NRF_ERROR_TIMEOUT); + break; + default: + // No implementation needed. + break; + } + } +} + + +/** + * @brief Routine called to actually issue the flash access request to the SoftDevice. + */ +static uint32_t process_cmd(void) +{ + uint32_t retval; + uint32_t storage_addr; + cmd_queue_element_t * p_cmd; + + retval = NRF_ERROR_FORBIDDEN; + + p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp]; + + storage_addr = p_cmd->storage_addr.block_id; + + if (p_cmd->op_code == PSTORAGE_CLEAR_OP_CODE) + { + // Calculate page number before copy. + uint32_t page_number; + + page_number = ((storage_addr / PSTORAGE_FLASH_PAGE_SIZE) + + m_round_val); + + retval = sd_flash_page_erase(page_number); + + if (NRF_SUCCESS == retval) + { + m_round_val++; + } + } + else if (p_cmd->op_code == PSTORAGE_STORE_OP_CODE) + { + uint32_t size; + uint8_t * p_data_addr = p_cmd->p_data_addr; + + p_data_addr += m_round_val; + + storage_addr += (p_cmd->offset + m_round_val); + + size = p_cmd->size - m_round_val; + + if (size < SOC_MAX_WRITE_SIZE) + { + retval = sd_flash_write(((uint32_t *)storage_addr), + (uint32_t *)p_data_addr, + size / sizeof(uint32_t)); + } + else + { + retval = sd_flash_write(((uint32_t *)storage_addr), + (uint32_t *)p_data_addr, + SOC_MAX_WRITE_SIZE / sizeof(uint32_t)); + } + + + if (retval == NRF_SUCCESS) + { + m_round_val += SOC_MAX_WRITE_SIZE; + } + } + else + { + // Should never reach here. + } + + if (retval == NRF_SUCCESS) + { + m_cmd_queue.flash_access = true; + } + + return retval; +} +/** @} */ + + +/** + * @brief Module initialization routine to be called once by the application. + */ +uint32_t pstorage_init(void) +{ + unsigned int index; + cmd_queue_init(); + + m_next_app_instance = 0; + m_next_page_addr = PSTORAGE_DATA_START_ADDR; + m_round_val = 0; + + for(index = 0; index < PSTORAGE_MAX_APPLICATIONS; index++) + { + m_app_table[index].cb = NULL; + m_app_table[index].block_size = 0; + m_app_table[index].no_of_pages = 0; + m_app_table[index].block_count = 0; + } + +#ifdef PSTORAGE_RAW_MODE_ENABLE + m_raw_app_table.cb = NULL; + m_raw_app_table.no_of_pages = 0; +#endif //PSTORAGE_RAW_MODE_ENABLE + + m_module_initialized = true; + return NRF_SUCCESS; +} + +/** + * @brief Registration routine to request persistent memory of certain sizes based on + * application module requirements. + */ +uint32_t pstorage_register(pstorage_module_param_t * p_module_param, + pstorage_handle_t * p_block_id) +{ + uint16_t page_count; + uint32_t total_size; + + VERIFY_MODULE_INITIALIZED(); + NULL_PARAM_CHECK(p_module_param); + NULL_PARAM_CHECK(p_block_id); + NULL_PARAM_CHECK(p_module_param->cb); + BLOCK_SIZE_CHECK(p_module_param->block_size); + BLOCK_COUNT_CHECK(p_module_param->block_count, p_module_param->block_size); + + if (m_next_app_instance == PSTORAGE_MAX_APPLICATIONS) + { + return NRF_ERROR_NO_MEM; + } + + p_block_id->module_id = m_next_app_instance; + p_block_id->block_id = m_next_page_addr; + m_app_table[m_next_app_instance].base_id = p_block_id->block_id; + m_app_table[m_next_app_instance].cb = p_module_param->cb; + m_app_table[m_next_app_instance].block_size = p_module_param->block_size; + m_app_table[m_next_app_instance].block_count = p_module_param->block_count; + + // Calculate number of flash pages allocated for the device. + page_count = 0; + total_size = p_module_param->block_size * p_module_param->block_count; + do + { + page_count++; + if (total_size > PSTORAGE_FLASH_PAGE_SIZE) + { + total_size -= PSTORAGE_FLASH_PAGE_SIZE; + } + else + { + total_size = 0; + } + m_next_page_addr += PSTORAGE_FLASH_PAGE_SIZE; + }while(total_size >= PSTORAGE_FLASH_PAGE_SIZE); + + m_app_table[m_next_app_instance].no_of_pages = page_count; + m_next_app_instance++; + + return NRF_SUCCESS; +} + + +/** + * @brief API to get the next block identifier. + */ +uint32_t pstorage_block_identifier_get(pstorage_handle_t * p_base_id, + pstorage_size_t block_num, + pstorage_handle_t * p_block_id) +{ + pstorage_handle_t temp_id; + + VERIFY_MODULE_INITIALIZED(); + NULL_PARAM_CHECK(p_base_id); + NULL_PARAM_CHECK(p_block_id); + MODULE_ID_RANGE_CHECK(p_base_id); + + temp_id = (*p_base_id); + temp_id.block_id += (block_num * MODULE_BLOCK_SIZE(p_base_id)); + BLOCK_ID_RANGE_CHECK(&temp_id); + (*p_block_id) = temp_id; + + return NRF_SUCCESS; +} + + +/** + * @brief API to store data persistently. + */ +uint32_t pstorage_store(pstorage_handle_t * p_dest, + uint8_t * p_src, + pstorage_size_t size, + pstorage_size_t offset) +{ + VERIFY_MODULE_INITIALIZED(); + NULL_PARAM_CHECK(p_src); + NULL_PARAM_CHECK(p_dest); + MODULE_ID_RANGE_CHECK (p_dest); + BLOCK_ID_RANGE_CHECK(p_dest); + SIZE_CHECK(p_dest,size); + OFFSET_CHECK(p_dest,offset,size); + + // Verify word alignment. + if ((!is_word_aligned(p_src)) || (!is_word_aligned(p_src+offset))) + { + return NRF_ERROR_INVALID_ADDR; + } + + return cmd_queue_enqueue(PSTORAGE_STORE_OP_CODE, p_dest, p_src, size, offset); +} + + +/** + * @brief API to load data from persistent memory. + */ +uint32_t pstorage_load(uint8_t * p_dest, + pstorage_handle_t * p_src, + pstorage_size_t size, + pstorage_size_t offset) +{ + VERIFY_MODULE_INITIALIZED(); + NULL_PARAM_CHECK(p_src); + NULL_PARAM_CHECK(p_dest); + MODULE_ID_RANGE_CHECK (p_src); + BLOCK_ID_RANGE_CHECK(p_src); + SIZE_CHECK(p_src,size); + OFFSET_CHECK(p_src,offset,size); + + // Verify word alignment. + if ((!is_word_aligned (p_dest)) || (!is_word_aligned (p_dest + offset))) + { + return NRF_ERROR_INVALID_ADDR; + } + + memcpy (p_dest, (((uint8_t *)p_src->block_id) + offset), size); + + return NRF_SUCCESS; +} + + +/** + * @brief API to clear data in blocks of persistent memory. + */ +uint32_t pstorage_clear(pstorage_handle_t * p_dest, pstorage_size_t size) +{ + uint32_t retval; + uint32_t pages; + + VERIFY_MODULE_INITIALIZED(); + NULL_PARAM_CHECK(p_dest); + MODULE_ID_RANGE_CHECK(p_dest); + BLOCK_ID_RANGE_CHECK(p_dest); + + pages = m_app_table[p_dest->module_id].no_of_pages; + + retval = cmd_queue_enqueue(PSTORAGE_CLEAR_OP_CODE, p_dest, NULL , pages , 0); + + return retval; +} + + +#ifdef PSTORAGE_RAW_MODE_ENABLE + +/** + * @brief Registration routine to request persistent memory of certain sizes based on + * application module requirements. + */ +uint32_t pstorage_raw_register(pstorage_module_param_t * p_module_param, + pstorage_handle_t * p_block_id) +{ + VERIFY_MODULE_INITIALIZED(); + NULL_PARAM_CHECK(p_module_param); + NULL_PARAM_CHECK(p_block_id); + NULL_PARAM_CHECK(p_module_param->cb); + + if (m_raw_app_table.cb != NULL) + { + return NRF_ERROR_NO_MEM; + } + + p_block_id->module_id = PSTORAGE_MAX_APPLICATIONS + 1; + m_raw_app_table.cb = p_module_param->cb; + + return NRF_SUCCESS; +} + + +/** + * @brief API to store data persistently. + */ +uint32_t pstorage_raw_store(pstorage_handle_t * p_dest, + uint8_t * p_src, + uint32_t size, + uint32_t offset) +{ + VERIFY_MODULE_INITIALIZED(); + NULL_PARAM_CHECK(p_src); + NULL_PARAM_CHECK(p_dest); + MODULE_RAW_ID_RANGE_CHECK(p_dest); + + // Verify word alignment. + if ((!is_word_aligned(p_src)) || (!is_word_aligned(p_src+offset))) + { + return NRF_ERROR_INVALID_ADDR; + } + + return cmd_queue_enqueue(PSTORAGE_STORE_OP_CODE, p_dest, p_src, size, offset); +} + + +/** + * @brief API to clear data in blocks of persistent memory. + */ +uint32_t pstorage_raw_clear(pstorage_handle_t * p_dest, uint32_t size) +{ + uint32_t retval; + uint32_t pages; + + VERIFY_MODULE_INITIALIZED(); + NULL_PARAM_CHECK(p_dest); + MODULE_RAW_ID_RANGE_CHECK(p_dest); + + retval = NRF_SUCCESS; + + pages = CEIL_DIV(size, PSTORAGE_FLASH_PAGE_SIZE); + + retval = cmd_queue_enqueue(PSTORAGE_CLEAR_OP_CODE, p_dest, NULL , pages, 0); + + return retval; +} + +#endif // PSTORAGE_RAW_MODE_ENABLE diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_advdata.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_advdata.cpp new file mode 100644 index 0000000000..4b8de1516a --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_advdata.cpp @@ -0,0 +1,624 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include "ble_advdata.h" +#include "nordic_common.h" +#include "nrf_error.h" +#include "ble_gap.h" +#include "ble_srv_common.h" +#include "app_util.h" + + +// Offset from where advertisement data other than flags information can start. +#define ADV_FLAG_OFFSET 2 + +// Offset for Advertising Data. +// Offset is 2 as each Advertising Data contain 1 octet of Adveritising Data Type and +// one octet Advertising Data Length. +#define ADV_DATA_OFFSET 2 + +// NOTE: For now, Security Manager TK Value and Security Manager Out of Band Flags (OOB) are omitted +// from the advertising data. + + +static uint32_t name_encode(const ble_advdata_t * p_advdata, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + uint32_t err_code; + uint16_t rem_adv_data_len; + uint16_t actual_length; + uint8_t adv_data_format; + uint8_t adv_offset; + + adv_offset = *p_len; + + + // Check for buffer overflow. + if ((adv_offset + ADV_DATA_OFFSET > BLE_GAP_ADV_MAX_SIZE) || + ((p_advdata->short_name_len + ADV_DATA_OFFSET) > BLE_GAP_ADV_MAX_SIZE)) + { + return NRF_ERROR_DATA_SIZE; + } + actual_length = rem_adv_data_len = (BLE_GAP_ADV_MAX_SIZE - adv_offset - ADV_FLAG_OFFSET); + + // Get GAP device name and length + err_code = sd_ble_gap_device_name_get(&p_encoded_data[adv_offset + ADV_DATA_OFFSET], + &actual_length); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Check if device internd to use short name and it can fit available data size. + if ((p_advdata->name_type == BLE_ADVDATA_FULL_NAME) && (actual_length <= rem_adv_data_len)) + { + // Complete device name can fit, setting Complete Name in Adv Data. + adv_data_format = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME; + rem_adv_data_len = actual_length; + } + else + { + // Else short name needs to be used. Or application has requested use of short name. + adv_data_format = BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME; + + // If application has set a preference on the short name size, it needs to be considered, + // else fit what can be fit. + if ((p_advdata->short_name_len != 0) && (p_advdata->short_name_len <= rem_adv_data_len)) + { + // Short name fits available size. + rem_adv_data_len = p_advdata->short_name_len; + } + // Else whatever can fit the data buffer will be packed. + else + { + rem_adv_data_len = actual_length; + } + } + + // Complete name field in encoded data. + p_encoded_data[adv_offset++] = rem_adv_data_len + 1; + p_encoded_data[adv_offset++] = adv_data_format; + (*p_len) += (rem_adv_data_len + ADV_DATA_OFFSET); + + return NRF_SUCCESS; +} + + +static uint32_t appearance_encode(uint8_t * p_encoded_data, uint8_t * p_len) +{ + uint32_t err_code; + uint16_t appearance; + + // Check for buffer overflow. + if ((*p_len) + 4 > BLE_GAP_ADV_MAX_SIZE) + { + return NRF_ERROR_DATA_SIZE; + } + + // Get GAP appearance field. + err_code = sd_ble_gap_appearance_get(&appearance); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Encode Length, AD Type and Appearance. + p_encoded_data[(*p_len)++] = 3; + p_encoded_data[(*p_len)++] = BLE_GAP_AD_TYPE_APPEARANCE; + + (*p_len) += uint16_encode(appearance, &p_encoded_data[*p_len]); + + return NRF_SUCCESS; +} + + +static uint32_t uint8_array_encode(const uint8_array_t * p_uint8_array, + uint8_t adv_type, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + // Check parameter consistency. + if (p_uint8_array->p_data == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Check for buffer overflow. + if ((*p_len) + ADV_DATA_OFFSET + p_uint8_array->size > BLE_GAP_ADV_MAX_SIZE) + { + return NRF_ERROR_DATA_SIZE; + } + + // Encode Length and AD Type. + p_encoded_data[(*p_len)++] = 1 + p_uint8_array->size; + p_encoded_data[(*p_len)++] = adv_type; + + // Encode array. + memcpy(&p_encoded_data[*p_len], p_uint8_array->p_data, p_uint8_array->size); + (*p_len) += p_uint8_array->size; + + return NRF_SUCCESS; +} + + +static uint32_t tx_power_level_encode(int8_t tx_power_level, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + // Check for buffer overflow. + if ((*p_len) + 3 > BLE_GAP_ADV_MAX_SIZE) + { + return NRF_ERROR_DATA_SIZE; + } + + // Encode TX Power Level. + p_encoded_data[(*p_len)++] = 2; + p_encoded_data[(*p_len)++] = BLE_GAP_AD_TYPE_TX_POWER_LEVEL; + p_encoded_data[(*p_len)++] = (uint8_t)tx_power_level; + + return NRF_SUCCESS; +} + + +static uint32_t uuid_list_sized_encode(const ble_advdata_uuid_list_t * p_uuid_list, + uint8_t adv_type, + uint8_t uuid_size, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + int i; + bool is_heading_written = false; + uint8_t start_pos = *p_len; + + for (i = 0; i < p_uuid_list->uuid_cnt; i++) + { + uint32_t err_code; + uint8_t encoded_size; + ble_uuid_t uuid = p_uuid_list->p_uuids[i]; + + // Find encoded uuid size. + err_code = sd_ble_uuid_encode(&uuid, &encoded_size, NULL); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Check size. + if (encoded_size == uuid_size) + { + uint8_t heading_bytes = (is_heading_written) ? 0 : 2; + + // Check for buffer overflow + if (*p_len + encoded_size + heading_bytes > BLE_GAP_ADV_MAX_SIZE) + { + return NRF_ERROR_DATA_SIZE; + } + + if (!is_heading_written) + { + // Write AD structure heading. + (*p_len)++; + p_encoded_data[(*p_len)++] = adv_type; + is_heading_written = true; + } + + // Write UUID. + err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &p_encoded_data[*p_len]); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + (*p_len) += encoded_size; + } + } + + if (is_heading_written) + { + // Write length. + p_encoded_data[start_pos] = (*p_len) - (start_pos + 1); + } + + return NRF_SUCCESS; +} + + +static uint32_t uuid_list_encode(const ble_advdata_uuid_list_t * p_uuid_list, + uint8_t adv_type_16, + uint8_t adv_type_128, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + uint32_t err_code; + + // Encode 16 bit UUIDs. + err_code = uuid_list_sized_encode(p_uuid_list, + adv_type_16, + sizeof(uint16_le_t), + p_encoded_data, + p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Encode 128 bit UUIDs. + err_code = uuid_list_sized_encode(p_uuid_list, + adv_type_128, + sizeof(ble_uuid128_t), + p_encoded_data, + p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + return NRF_SUCCESS; +} + + +static uint32_t conn_int_check(const ble_advdata_conn_int_t *p_conn_int) +{ + // Check Minimum Connection Interval. + if ((p_conn_int->min_conn_interval < 0x0006) || + ( + (p_conn_int->min_conn_interval > 0x0c80) && + (p_conn_int->min_conn_interval != 0xffff) + ) + ) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Check Maximum Connection Interval. + if ((p_conn_int->max_conn_interval < 0x0006) || + ( + (p_conn_int->max_conn_interval > 0x0c80) && + (p_conn_int->max_conn_interval != 0xffff) + ) + ) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Make sure Minimum Connection Interval is not bigger than Maximum Connection Interval. + if ((p_conn_int->min_conn_interval != 0xffff) && + (p_conn_int->max_conn_interval != 0xffff) && + (p_conn_int->min_conn_interval > p_conn_int->max_conn_interval) + ) + { + return NRF_ERROR_INVALID_PARAM; + } + + return NRF_SUCCESS; +} + + +static uint32_t conn_int_encode(const ble_advdata_conn_int_t * p_conn_int, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + uint32_t err_code; + + // Check for buffer overflow. + if ((*p_len) + ADV_DATA_OFFSET + 2 * sizeof(uint16_le_t) > BLE_GAP_ADV_MAX_SIZE) + { + return NRF_ERROR_DATA_SIZE; + } + + // Check parameters. + err_code = conn_int_check(p_conn_int); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Encode Length and AD Type. + p_encoded_data[(*p_len)++] = 1 + 2 * sizeof(uint16_le_t); + p_encoded_data[(*p_len)++] = BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE; + + // Encode Minimum and Maximum Connection Intervals. + (*p_len) += uint16_encode(p_conn_int->min_conn_interval, &p_encoded_data[*p_len]); + (*p_len) += uint16_encode(p_conn_int->max_conn_interval, &p_encoded_data[*p_len]); + + return NRF_SUCCESS; +} + + +static uint32_t manuf_specific_data_encode(const ble_advdata_manuf_data_t * p_manuf_sp_data, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + uint8_t data_size = sizeof(uint16_le_t) + p_manuf_sp_data->data.size; + + // Check for buffer overflow. + if ((*p_len) + ADV_DATA_OFFSET + data_size > BLE_GAP_ADV_MAX_SIZE) + { + return NRF_ERROR_DATA_SIZE; + } + + // Encode Length and AD Type. + p_encoded_data[(*p_len)++] = 1 + data_size; + p_encoded_data[(*p_len)++] = BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA; + + // Encode Company Identifier. + (*p_len) += uint16_encode(p_manuf_sp_data->company_identifier, &p_encoded_data[*p_len]); + + // Encode additional manufacturer specific data. + if (p_manuf_sp_data->data.size > 0) + { + if (p_manuf_sp_data->data.p_data == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + memcpy(&p_encoded_data[*p_len], p_manuf_sp_data->data.p_data, p_manuf_sp_data->data.size); + (*p_len) += p_manuf_sp_data->data.size; + } + + return NRF_SUCCESS; +} + + +static uint32_t service_data_encode(const ble_advdata_t * p_advdata, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + uint8_t i; + + // Check parameter consistency. + if (p_advdata->p_service_data_array == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + for (i = 0; i < p_advdata->service_data_count; i++) + { + ble_advdata_service_data_t * p_service_data; + uint8_t data_size; + + p_service_data = &p_advdata->p_service_data_array[i]; + data_size = sizeof(uint16_le_t) + p_service_data->data.size; + + // Encode Length and AD Type. + p_encoded_data[(*p_len)++] = 1 + data_size; + p_encoded_data[(*p_len)++] = BLE_GAP_AD_TYPE_SERVICE_DATA; + + // Encode service UUID. + (*p_len) += uint16_encode(p_service_data->service_uuid, &p_encoded_data[*p_len]); + + // Encode additional service data. + if (p_service_data->data.size > 0) + { + if (p_service_data->data.p_data == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + memcpy(&p_encoded_data[*p_len], p_service_data->data.p_data, p_service_data->data.size); + (*p_len) += p_service_data->data.size; + } + } + + return NRF_SUCCESS; +} + + +static uint32_t adv_data_encode(const ble_advdata_t * p_advdata, + uint8_t * p_encoded_data, + uint8_t * p_len) +{ + uint32_t err_code = NRF_SUCCESS; + + *p_len = 0; + + // Encode name. + if (p_advdata->name_type != BLE_ADVDATA_NO_NAME) + { + err_code = name_encode(p_advdata, p_encoded_data, p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode appearance. + if (p_advdata->include_appearance) + { + err_code = appearance_encode(p_encoded_data, p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode flags. + if (p_advdata->flags.size > 0) + { + err_code = uint8_array_encode(&p_advdata->flags, + BLE_GAP_AD_TYPE_FLAGS, + p_encoded_data, + p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode TX power level. + if (p_advdata->p_tx_power_level != NULL) + { + err_code = tx_power_level_encode(*p_advdata->p_tx_power_level, p_encoded_data, p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode 'more available' uuid list. + if (p_advdata->uuids_more_available.uuid_cnt > 0) + { + err_code = uuid_list_encode(&p_advdata->uuids_more_available, + BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE, + BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE, + p_encoded_data, + p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode 'complete' uuid list. + if (p_advdata->uuids_complete.uuid_cnt > 0) + { + err_code = uuid_list_encode(&p_advdata->uuids_complete, + BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE, + BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, + p_encoded_data, + p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode 'solicited service' uuid list. + if (p_advdata->uuids_solicited.uuid_cnt > 0) + { + err_code = uuid_list_encode(&p_advdata->uuids_solicited, + BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT, + BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT, + p_encoded_data, + p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode Slave Connection Interval Range. + if (p_advdata->p_slave_conn_int != NULL) + { + err_code = conn_int_encode(p_advdata->p_slave_conn_int, p_encoded_data, p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode Manufacturer Specific Data. + if (p_advdata->p_manuf_specific_data != NULL) + { + err_code = manuf_specific_data_encode(p_advdata->p_manuf_specific_data, + p_encoded_data, + p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Encode Service Data. + if (p_advdata->service_data_count > 0) + { + err_code = service_data_encode(p_advdata, p_encoded_data, p_len); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + return err_code; +} + + +static uint32_t advdata_check(const ble_advdata_t * p_advdata) +{ + // Flags must be included in advertising data, and the BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED flag must be set. + if ((p_advdata->flags.size == 0) || + (p_advdata->flags.p_data == NULL) || + ((p_advdata->flags.p_data[0] & BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) == 0) + ) + { + return NRF_ERROR_INVALID_PARAM; + } + + return NRF_SUCCESS; +} + + +static uint32_t srdata_check(const ble_advdata_t * p_srdata) +{ + // Flags shall not be included in the scan response data. + if (p_srdata->flags.size > 0) + { + return NRF_ERROR_INVALID_PARAM; + } + + return NRF_SUCCESS; +} + + +uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata) +{ + uint32_t err_code; + uint8_t len_advdata = 0; + uint8_t len_srdata = 0; + uint8_t encoded_advdata[BLE_GAP_ADV_MAX_SIZE]; + uint8_t encoded_srdata[BLE_GAP_ADV_MAX_SIZE]; + uint8_t * p_encoded_advdata; + uint8_t * p_encoded_srdata; + + // Encode advertising data (if supplied). + if (p_advdata != NULL) + { + err_code = advdata_check(p_advdata); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + err_code = adv_data_encode(p_advdata, encoded_advdata, &len_advdata); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + p_encoded_advdata = encoded_advdata; + } + else + { + p_encoded_advdata = NULL; + } + + // Encode scan response data (if supplied). + if (p_srdata != NULL) + { + err_code = srdata_check(p_srdata); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + err_code = adv_data_encode(p_srdata, encoded_srdata, &len_srdata); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + p_encoded_srdata = encoded_srdata; + } + else + { + p_encoded_srdata = NULL; + } + + // Pass encoded advertising data and/or scan response data to the stack. + return sd_ble_gap_adv_data_set(p_encoded_advdata, len_advdata, p_encoded_srdata, len_srdata); +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_advdata_parser.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_advdata_parser.cpp new file mode 100644 index 0000000000..4e5c73d4e7 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_advdata_parser.cpp @@ -0,0 +1,21 @@ +#include "ble_advdata_parser.h" + +uint32_t ble_advdata_parser_field_find(uint8_t type, uint8_t * p_advdata, uint8_t * len, uint8_t ** pp_field_data) +{ + uint32_t index = 0; + + while (index < *len) + { + uint8_t field_length = p_advdata[index]; + uint8_t field_type = p_advdata[index+1]; + + if (field_type == type) + { + *pp_field_data = &p_advdata[index+2]; + *len = field_length-1; + return NRF_SUCCESS; + } + index += field_length+1; + } + return NRF_ERROR_NOT_FOUND; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_bondmngr.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_bondmngr.cpp new file mode 100644 index 0000000000..2696661cdf --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_bondmngr.cpp @@ -0,0 +1,1594 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include "ble_bondmngr.h" +#include +#include +#include +#include "nordic_common.h" +#include "nrf_error.h" +#include "ble_gap.h" +#include "ble_srv_common.h" +#include "app_util.h" +#include "nrf_assert.h" +//#include "nrf.h" +#include "nrf51_bitfields.h" +#include "crc16.h" +#include "pstorage.h" +#include "ble_bondmngr_cfg.h" + +#define CCCD_SIZE 6 /**< Number of bytes needed for storing the state of one CCCD. */ +#define CRC_SIZE 2 /**< Size of CRC in sys_attribute data. */ +#define SYS_ATTR_BUFFER_MAX_LEN (((BLE_BONDMNGR_CCCD_COUNT + 1) * CCCD_SIZE) + CRC_SIZE) /**< Size of sys_attribute data. */ +#define MAX_NUM_CENTRAL_WHITE_LIST MIN(BLE_BONDMNGR_MAX_BONDED_CENTRALS, 8) /**< Maximum number of whitelisted centrals supported.*/ +#define MAX_BONDS_IN_FLASH 10 /**< Maximum number of bonds that can be stored in flash. */ +#define BOND_MANAGER_DATA_SIGNATURE 0x53240000 + +/**@defgroup ble_bond_mngr_sec_access Bond Manager Security Status Access Macros + * @brief The following group of macros abstract access to Security Status with a peer. + * @{ + */ + +#define SEC_STATUS_INIT_VAL 0x00 /**< Initialization value for security status flags. */ +#define ENC_STATUS_SET_VAL 0x01 /**< Bitmask for encryption status. */ +#define BOND_IN_PROGRESS_SET_VAL 0x02 /**< Bitmask for 'bonding in progress'. */ + + +/**@brief Macro for setting the Encryption Status for current link. + * + * @details Macro for setting the Encryption Status for current link. + */ +#define ENCRYPTION_STATUS_SET() \ + do \ + { \ + m_sec_con_status |= ENC_STATUS_SET_VAL; \ + } while (0) + +/**@brief Macro for getting the Encryption Status for current link. + * + * @details Macro for getting the Encryption Status for current link. + */ +#define ENCRYPTION_STATUS_GET() \ + (((m_sec_con_status & ENC_STATUS_SET_VAL) == 0) ? false : true) + +/**@brief Macro for resetting the Encryption Status for current link. + * + * @details Macro for resetting the Encryption Status for current link. + */ +#define ENCRYPTION_STATUS_RESET() \ + do \ + { \ + m_sec_con_status &= (~ENC_STATUS_SET_VAL); \ + } while (0) + + +/**@brief Macro for resetting the Bonding In Progress status for current link. + * + * @details Macro for resetting the Bonding In Progress status for current link. + */ +#define BONDING_IN_PROGRESS_STATUS_SET() \ + do \ + { \ + m_sec_con_status |= BOND_IN_PROGRESS_SET_VAL; \ + } while (0) + +/**@brief Macro for setting the Bonding In Progress status for current link. + * + * @details Macro for setting the Bonding In Progress status for current link. + */ +#define BONDING_IN_PROGRESS_STATUS_GET() \ + (((m_sec_con_status & BOND_IN_PROGRESS_SET_VAL) == 0) ? false: true) + +/**@brief Macro for resetting the Bonding In Progress status for current link. + * + * @details Macro for resetting the Bonding In Progress status for current link. + */ +#define BONDING_IN_PROGRESS_STATUS_RESET() \ + do \ + { \ + m_sec_con_status &= (~BOND_IN_PROGRESS_SET_VAL); \ + } while (0) + +/**@brief Macro for resetting all security status flags for current link. + * + * @details Macro for resetting all security status flags for current link. + */ +#define SECURITY_STATUS_RESET() \ + do \ + { \ + m_sec_con_status = SEC_STATUS_INIT_VAL; \ + } while (0) + +/** @} */ + +/**@brief Verify module's initialization status. + * + * @details Verify module's initialization status. Returns NRF_INVALID_STATE in case a module API + * is called without initializing the module. + */ +#define VERIFY_MODULE_INITIALIZED() \ + do \ + { \ + if (!m_is_bondmngr_initialized) \ + { \ + return NRF_ERROR_INVALID_STATE; \ + } \ + } while(0) + + +/**@brief This structure contains the Bonding Information for one central. + */ +typedef struct +{ + int32_t central_handle; /**< Central's handle (NOTE: Size is 32 bits just to make struct size dividable by 4). */ + ble_gap_evt_auth_status_t auth_status; /**< Central authentication data. */ + ble_gap_evt_sec_info_request_t central_id_info; /**< Central identification info. */ + ble_gap_addr_t central_addr; /**< Central's address. */ +} central_bond_t; + +STATIC_ASSERT(sizeof(central_bond_t) % 4 == 0); + +/**@brief This structure contains the System Attributes information related to one central. + */ +typedef struct +{ + int32_t central_handle; /**< Central's handle (NOTE: Size is 32 bits just to make struct size dividable by 4). */ + uint8_t sys_attr[SYS_ATTR_BUFFER_MAX_LEN]; /**< Central sys_attribute data. */ + uint32_t sys_attr_size; /**< Central sys_attribute data's size (NOTE: Size is 32 bits just to make struct size dividable by 4). */ +} central_sys_attr_t; + +STATIC_ASSERT(sizeof(central_sys_attr_t) % 4 == 0); + +/**@brief This structure contains the Bonding Information and System Attributes related to one + * central. + */ +typedef struct +{ + central_bond_t bond; /**< Bonding information. */ + central_sys_attr_t sys_attr; /**< System attribute information. */ +} central_t; + +/**@brief This structure contains the whitelisted addresses. + */ +typedef struct +{ + int8_t central_handle; /**< Central's handle. */ + ble_gap_addr_t * p_addr; /**< Pointer to the central's address if BLE_GAP_ADDR_TYPE_PUBLIC. */ +} whitelist_addr_t; + +/**@brief This structure contains the whitelisted IRKs. + */ +typedef struct +{ + int8_t central_handle; /**< Central's handle. */ + ble_gap_irk_t * p_irk; /**< Pointer to the central's irk if available. */ +} whitelist_irk_t; + +static bool m_is_bondmngr_initialized = false; /**< Flag for checking if module has been initialized. */ +static ble_bondmngr_init_t m_bondmngr_config; /**< Configuration as specified by the application. */ +static uint16_t m_conn_handle; /**< Current connection handle. */ +static central_t m_central; /**< Current central data. */ +static central_t m_centrals_db[BLE_BONDMNGR_MAX_BONDED_CENTRALS]; /**< Pointer to start of bonded centrals database. */ +static uint8_t m_centrals_in_db_count; /**< Number of bonded centrals. */ +static whitelist_addr_t m_whitelist_addr[MAX_NUM_CENTRAL_WHITE_LIST]; /**< List of central's addresses for the whitelist. */ +static whitelist_irk_t m_whitelist_irk[MAX_NUM_CENTRAL_WHITE_LIST]; /**< List of central's IRKs for the whitelist. */ +static uint8_t m_addr_count; /**< Number of addresses in the whitelist. */ +static uint8_t m_irk_count; /**< Number of IRKs in the whitelist. */ +static uint16_t m_crc_bond_info; /**< Combined CRC for all Bonding Information currently stored in flash. */ +static uint16_t m_crc_sys_attr; /**< Combined CRC for all System Attributes currently stored in flash. */ +static pstorage_handle_t mp_flash_bond_info; /**< Pointer to flash location to write next Bonding Information. */ +static pstorage_handle_t mp_flash_sys_attr; /**< Pointer to flash location to write next System Attribute information. */ +static uint8_t m_bond_info_in_flash_count; /**< Number of Bonding Information currently stored in flash. */ +static uint8_t m_sys_attr_in_flash_count; /**< Number of System Attributes currently stored in flash. */ +static uint8_t m_sec_con_status; /**< Variable to denote security status.*/ +static bool m_bond_loaded; /**< Variable to indicate if the bonding information of the currently connected central is available in the RAM.*/ +static bool m_sys_attr_loaded; /**< Variable to indicate if the system attribute information of the currently connected central is loaded from the database and set in the S110 SoftDevice.*/ +static uint32_t m_bond_crc_array[BLE_BONDMNGR_MAX_BONDED_CENTRALS]; +static uint32_t m_sys_crc_array[BLE_BONDMNGR_MAX_BONDED_CENTRALS]; + +/**@brief Function for extracting the CRC from an encoded 32 bit number that typical resides in + * the flash memory + * + * @param[in] header Header containing CRC and magic number. + * @param[out] p_crc Extracted CRC. + * + * @retval NRF_SUCCESS CRC successfully extracted. + * @retval NRF_ERROR_NOT_FOUND Flash seems to be empty. + * @retval NRF_ERROR_INVALID_DATA Header does not contain the magic number. + */ +static uint32_t crc_extract(uint32_t header, uint16_t * p_crc) +{ + if ((header & 0xFFFF0000U) == BOND_MANAGER_DATA_SIGNATURE) + { + *p_crc = (uint16_t)(header & 0x0000FFFFU); + + return NRF_SUCCESS; + } + else if (header == 0xFFFFFFFFU) + { + return NRF_ERROR_NOT_FOUND; + } + else + { + return NRF_ERROR_INVALID_DATA; + } +} + + +/**@brief Function for storing the Bonding Information of the specified central to the flash. + * + * @param[in] p_bond Bonding information to be stored. + * + * @return NRF_SUCCESS on success, an error_code otherwise. + */ +static uint32_t bond_info_store(central_bond_t * p_bond) +{ + uint32_t err_code; + pstorage_handle_t dest_block; + + // Check if flash is full + if (m_bond_info_in_flash_count >= MAX_BONDS_IN_FLASH) + { + return NRF_ERROR_NO_MEM; + } + + // Check if this is the first bond to be stored + if (m_bond_info_in_flash_count == 0) + { + // Initialize CRC + m_crc_bond_info = crc16_compute(NULL, 0, NULL); + } + + // Get block pointer from base + err_code = pstorage_block_identifier_get(&mp_flash_bond_info,m_bond_info_in_flash_count,&dest_block); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Write Bonding Information + err_code = pstorage_store(&dest_block, + (uint8_t *)p_bond, + sizeof(central_bond_t), + sizeof(uint32_t)); + + if (err_code != NRF_SUCCESS) + { + return err_code; + } + m_crc_bond_info = crc16_compute((uint8_t *)p_bond, + sizeof(central_bond_t), + &m_crc_bond_info); + + // Write header + m_bond_crc_array[m_bond_info_in_flash_count] = (BOND_MANAGER_DATA_SIGNATURE | m_crc_bond_info); + + err_code = pstorage_store (&dest_block, (uint8_t *)&m_bond_crc_array[m_bond_info_in_flash_count],sizeof(uint32_t),0); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_bond_info_in_flash_count++; + return NRF_SUCCESS; +} + + +/**@brief Function for storing the System Attributes related to a specified central in flash. + * + * @param[in] p_sys_attr System Attributes to be stored. + * + * @return NRF_SUCCESS on success, an error_code otherwise. + */ +static uint32_t sys_attr_store(central_sys_attr_t * p_sys_attr) +{ + uint32_t err_code; + pstorage_handle_t dest_block; + + // Check if flash is full. + if (m_sys_attr_in_flash_count >= MAX_BONDS_IN_FLASH) + { + return NRF_ERROR_NO_MEM; + } + + // Check if this is the first time any System Attributes is stored. + if (m_sys_attr_in_flash_count == 0) + { + // Initialize CRC + m_crc_sys_attr = crc16_compute(NULL, 0, NULL); + } + + + // Get block pointer from base + err_code = pstorage_block_identifier_get(&mp_flash_sys_attr,m_sys_attr_in_flash_count,&dest_block); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Write System Attributes in flash. + err_code = pstorage_store(&dest_block, + (uint8_t *)p_sys_attr, + sizeof(central_sys_attr_t), + sizeof(uint32_t)); + + if (err_code != NRF_SUCCESS) + { + return err_code; + } + m_crc_sys_attr = crc16_compute((uint8_t *)p_sys_attr, + sizeof(central_sys_attr_t), + &m_crc_sys_attr); + + // Write header. + m_sys_crc_array[m_sys_attr_in_flash_count] = (BOND_MANAGER_DATA_SIGNATURE | m_crc_sys_attr); + + err_code = pstorage_store (&dest_block, + (uint8_t *)&m_sys_crc_array[m_sys_attr_in_flash_count], + sizeof(uint32_t), + 0); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_sys_attr_in_flash_count++; + + + return NRF_SUCCESS; +} + + +/**@brief Function for loading the Bonding Information of one central from flash. + * + * @param[out] p_bond Loaded Bonding Information. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t bonding_info_load_from_flash(central_bond_t * p_bond) +{ + pstorage_handle_t source_block; + uint32_t err_code; + uint32_t crc; + uint16_t crc_header; + + // Check if this is the first bond to be loaded, in which case the + // m_bond_info_in_flash_count variable would have the intial value 0. + if (m_bond_info_in_flash_count == 0) + { + // Initialize CRC. + m_crc_bond_info = crc16_compute(NULL, 0, NULL); + } + + // Get block pointer from base + err_code = pstorage_block_identifier_get(&mp_flash_bond_info, + m_bond_info_in_flash_count, + &source_block); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + err_code = pstorage_load((uint8_t *)&crc, &source_block, sizeof(uint32_t), 0); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Extract CRC from header. + err_code = crc_extract(crc, &crc_header); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Load central. + err_code = pstorage_load((uint8_t *)p_bond, + &source_block, + sizeof(central_bond_t), + sizeof(uint32_t)); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Check CRC. + m_crc_bond_info = crc16_compute((uint8_t *)p_bond, + sizeof(central_bond_t), + &m_crc_bond_info); + if (m_crc_bond_info == crc_header) + { + m_bond_info_in_flash_count++; + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_INVALID_DATA; + } +} + + + +/**@brief Function for loading the System Attributes related to one central from flash. + * + * @param[out] p_sys_attr Loaded System Attributes. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t sys_attr_load_from_flash(central_sys_attr_t * p_sys_attr) +{ + pstorage_handle_t source_block; + uint32_t err_code; + uint32_t crc; + uint16_t crc_header; + + // Check if this is the first time System Attributes is loaded from flash, in which case the + // m_sys_attr_in_flash_count variable would have the initial value 0. + if (m_sys_attr_in_flash_count == 0) + { + // Initialize CRC. + m_crc_sys_attr = crc16_compute(NULL, 0, NULL); + } + + // Get block pointer from base + err_code = pstorage_block_identifier_get(&mp_flash_sys_attr, + m_sys_attr_in_flash_count, + &source_block); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + err_code = pstorage_load((uint8_t *)&crc, &source_block, sizeof(uint32_t), 0); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Extract CRC from header. + err_code = crc_extract(crc, &crc_header); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + err_code = pstorage_load((uint8_t *)p_sys_attr, + &source_block, + sizeof(central_sys_attr_t), + sizeof(uint32_t)); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Check CRC. + m_crc_sys_attr = crc16_compute((uint8_t *)p_sys_attr, + sizeof(central_sys_attr_t), + &m_crc_sys_attr); + + if (m_crc_sys_attr == crc_header) + { + m_sys_attr_in_flash_count++; + return NRF_SUCCESS; + } + else + { + return NRF_ERROR_INVALID_DATA; + } +} + + +/**@brief Function for erasing the flash pages that contain Bonding Information and System + * Attributes. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t flash_pages_erase(void) +{ + uint32_t err_code; + + err_code = pstorage_clear(&mp_flash_bond_info, MAX_BONDS_IN_FLASH); + + if (err_code == NRF_SUCCESS) + { + err_code = pstorage_clear(&mp_flash_sys_attr, MAX_BONDS_IN_FLASH); + } + + return err_code; +} + + +/**@brief Function for checking if Bonding Information in RAM is different from that in + * flash. + * + * @return TRUE if Bonding Information in flash and RAM are different, FALSE otherwise. + */ +static bool bond_info_changed(void) +{ + int i; + uint16_t crc = crc16_compute(NULL, 0, NULL); + + // Compute CRC for all bonds in database. + for (i = 0; i < m_centrals_in_db_count; i++) + { + crc = crc16_compute((uint8_t *)&m_centrals_db[i].bond, + sizeof(central_bond_t), + &crc); + } + + // Compare the computed CRS to CRC stored in flash. + return (crc != m_crc_bond_info); +} + + +/**@brief Function for checking if System Attributes in RAM is different from that in flash. + * + * @return TRUE if System Attributes in flash and RAM are different, FALSE otherwise. + */ +static bool sys_attr_changed(void) +{ + int i; + uint16_t crc = crc16_compute(NULL, 0, NULL); + + // Compute CRC for all System Attributes in database. + for (i = 0; i < m_centrals_in_db_count; i++) + { + crc = crc16_compute((uint8_t *)&m_centrals_db[i].sys_attr, + sizeof(central_sys_attr_t), + &crc); + } + + // Compare the CRC of System Attributes in flash with that of the System Attributes in memory. + return (crc != m_crc_sys_attr); +} + + +/**@brief Function for setting the System Attributes for specified central to the SoftDevice, or + * clearing the System Attributes if central is a previously unknown. + * + * @param[in] p_central Central for which the System Attributes is to be set. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t central_sys_attr_set(central_t * p_central) +{ + uint8_t * p_sys_attr; + + if (m_central.sys_attr.sys_attr_size != 0) + { + if (m_central.sys_attr.sys_attr_size > SYS_ATTR_BUFFER_MAX_LEN) + { + return NRF_ERROR_INTERNAL; + } + + p_sys_attr = m_central.sys_attr.sys_attr; + } + else + { + p_sys_attr = NULL; + } + + return sd_ble_gatts_sys_attr_set(m_conn_handle, p_sys_attr, m_central.sys_attr.sys_attr_size); +} + + +/**@brief Function for updating the whitelist data structures. + */ +static void update_whitelist(void) +{ + int i; + + for (i = 0, m_addr_count = 0, m_irk_count = 0; i < m_centrals_in_db_count; i++) + { + central_bond_t * p_bond = &m_centrals_db[i].bond; + + if (p_bond->auth_status.central_kex.irk) + { + m_whitelist_irk[m_irk_count].central_handle = p_bond->central_handle; + m_whitelist_irk[m_irk_count].p_irk = &(p_bond->auth_status.central_keys.irk); + + m_irk_count++; + } + + if (p_bond->central_addr.addr_type != BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE) + { + m_whitelist_addr[m_addr_count].central_handle = p_bond->central_handle; + m_whitelist_addr[m_addr_count].p_addr = &(p_bond->central_addr); + + m_addr_count++; + } + } +} + + +/**@brief Function for handling the authentication status event related to a new central. + * + * @details This function adds the new central to the database and stores the central's Bonding + * Information to flash. It also notifies the application when the new bond is created, + * and sets the System Attributes to prepare the stack for connection with the new + * central. + * + * @param[in] p_auth_status New authentication status. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t on_auth_status_from_new_central(ble_gap_evt_auth_status_t * p_auth_status) +{ + uint32_t err_code; + + if (m_centrals_in_db_count >= BLE_BONDMNGR_MAX_BONDED_CENTRALS) + { + return NRF_ERROR_NO_MEM; + } + + // Update central. + m_central.bond.auth_status = *p_auth_status; + m_central.bond.central_id_info.div = p_auth_status->periph_keys.enc_info.div; + m_central.sys_attr.sys_attr_size = 0; + + // Add new central to database. + m_central.bond.central_handle = m_centrals_in_db_count; + m_centrals_db[m_centrals_in_db_count++] = m_central; + + update_whitelist(); + + m_bond_loaded = true; + + // Clear System Attributes. + err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Write new central's Bonding Information to flash. + err_code = bond_info_store(&m_central.bond); + if ((err_code == NRF_ERROR_NO_MEM) && (m_bondmngr_config.evt_handler != NULL)) + { + ble_bondmngr_evt_t evt; + + evt.evt_type = BLE_BONDMNGR_EVT_BOND_FLASH_FULL; + evt.central_handle = m_central.bond.central_handle; + evt.central_id = m_central.bond.central_id_info.div; + + m_bondmngr_config.evt_handler(&evt); + } + else if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Pass the event to application. + if (m_bondmngr_config.evt_handler != NULL) + { + ble_bondmngr_evt_t evt; + + evt.evt_type = BLE_BONDMNGR_EVT_NEW_BOND; + evt.central_handle = m_central.bond.central_handle; + evt.central_id = m_central.bond.central_id_info.div; + + m_bondmngr_config.evt_handler(&evt); + } + + return NRF_SUCCESS; +} + + +/**@brief Function for updating the current central's entry in the database. + */ +static uint32_t central_update(void) +{ + uint32_t err_code; + int32_t central_handle = m_central.bond.central_handle; + + if ((central_handle >= 0) && (central_handle < m_centrals_in_db_count)) + { + // Update the database based on whether the bond and system attributes have + // been loaded or not to avoid overwriting information that was not used in the + // connection session. + if (m_bond_loaded) + { + m_centrals_db[central_handle].bond = m_central.bond; + } + + if (m_sys_attr_loaded) + { + m_centrals_db[central_handle].sys_attr = m_central.sys_attr; + } + + update_whitelist(); + + err_code = NRF_SUCCESS; + } + else + { + err_code = NRF_ERROR_INTERNAL; + } + + return err_code; +} + + +/**@brief Function for searching for the central in the database of known centrals. + * + * @details If the central is found, the variable m_central will be populated with all the + * information (Bonding Information and System Attributes) related to that central. + * + * @param[in] central_id Central Identifier. + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t central_find_in_db(uint16_t central_id) +{ + int i; + + for (i = 0; i < m_centrals_in_db_count; i++) + { + if (central_id == m_centrals_db[i].bond.central_id_info.div) + { + m_central = m_centrals_db[i]; + return NRF_SUCCESS; + } + } + + return NRF_ERROR_NOT_FOUND; +} + + +/**@brief Function for loading all Bonding Information and System Attributes from flash. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +static uint32_t load_all_from_flash(void) +{ + uint32_t err_code; + int i; + + m_centrals_in_db_count = 0; + + while (m_centrals_in_db_count < BLE_BONDMNGR_MAX_BONDED_CENTRALS) + { + central_bond_t central_bond_info; + int central_handle; + + // Load Bonding Information. + err_code = bonding_info_load_from_flash(¢ral_bond_info); + if (err_code == NRF_ERROR_NOT_FOUND) + { + // No more bonds in flash. + break; + } + else if (err_code != NRF_SUCCESS) + { + return err_code; + } + + central_handle = central_bond_info.central_handle; + if (central_handle > m_centrals_in_db_count) + { + // Central handle value(s) missing in flash. This should never happen. + return NRF_ERROR_INVALID_DATA; + } + else + { + // Add/update Bonding Information in central array. + m_centrals_db[central_handle].bond = central_bond_info; + if (central_handle == m_centrals_in_db_count) + { + // New central handle, clear System Attributes. + m_centrals_db[central_handle].sys_attr.sys_attr_size = 0; + m_centrals_db[central_handle].sys_attr.central_handle = INVALID_CENTRAL_HANDLE; + m_centrals_in_db_count++; + } + else + { + // Entry was updated, do nothing. + } + } + } + + // Load System Attributes for all previously known centrals. + for (i = 0; i < m_centrals_in_db_count; i++) + { + central_sys_attr_t central_sys_attr; + + // Load System Attributes. + err_code = sys_attr_load_from_flash(¢ral_sys_attr); + if (err_code == NRF_ERROR_NOT_FOUND) + { + // No more System Attributes in flash. + break; + } + else if (err_code != NRF_SUCCESS) + { + return err_code; + } + + if (central_sys_attr.central_handle > m_centrals_in_db_count) + { + // Central handle value(s) missing in flash. This should never happen. + return NRF_ERROR_INVALID_DATA; + } + else + { + // Add/update Bonding Information in central array. + m_centrals_db[central_sys_attr.central_handle].sys_attr = central_sys_attr; + } + } + + // Initialize the remaining empty bond entries in the memory. + for (i = m_centrals_in_db_count; i < BLE_BONDMNGR_MAX_BONDED_CENTRALS; i++) + { + m_centrals_db[i].bond.central_handle = INVALID_CENTRAL_HANDLE; + m_centrals_db[i].sys_attr.sys_attr_size = 0; + m_centrals_db[i].sys_attr.central_handle = INVALID_CENTRAL_HANDLE; + } + + // Update whitelist data structures. + update_whitelist(); + + return NRF_SUCCESS; +} + + +/**@brief Function for handling the connected event received from the BLE stack. + * + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_connect(ble_evt_t * p_ble_evt) +{ + m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + + m_central.bond.central_handle = INVALID_CENTRAL_HANDLE; + m_central.bond.central_addr = p_ble_evt->evt.gap_evt.params.connected.peer_addr; + m_central.sys_attr.sys_attr_size = 0; + + if (p_ble_evt->evt.gap_evt.params.connected.irk_match) + { + uint8_t irk_idx = p_ble_evt->evt.gap_evt.params.connected.irk_match_idx; + + if ((irk_idx >= MAX_NUM_CENTRAL_WHITE_LIST) || + (m_whitelist_irk[irk_idx].central_handle >= BLE_BONDMNGR_MAX_BONDED_CENTRALS)) + { + m_bondmngr_config.error_handler(NRF_ERROR_INTERNAL); + } + else + { + m_central = m_centrals_db[m_whitelist_irk[irk_idx].central_handle]; + } + } + else + { + int i; + + for (i = 0; i < m_addr_count; i++) + { + ble_gap_addr_t * p_cur_addr = m_whitelist_addr[i].p_addr; + + if (memcmp(p_cur_addr->addr, m_central.bond.central_addr.addr, BLE_GAP_ADDR_LEN) == 0) + { + m_central = m_centrals_db[m_whitelist_addr[i].central_handle]; + break; + } + } + } + + if (m_central.bond.central_handle != INVALID_CENTRAL_HANDLE) + { + // Reset bond and system attributes loaded variables. + m_bond_loaded = false; + m_sys_attr_loaded = false; + + // Do not set the system attributes of the central on connection. + if (m_bondmngr_config.evt_handler != NULL) + { + ble_bondmngr_evt_t evt; + + evt.evt_type = BLE_BONDMNGR_EVT_CONN_TO_BONDED_CENTRAL; + evt.central_handle = m_central.bond.central_handle; + evt.central_id = m_central.bond.central_id_info.div; + + m_bondmngr_config.evt_handler(&evt); + } + } +} + + +/**@brief Function for handling the 'System Attributes Missing' event received from the + * SoftDevice. + * + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_sys_attr_missing(ble_evt_t * p_ble_evt) +{ + uint32_t err_code; + + if ( + (m_central.bond.central_handle == INVALID_CENTRAL_HANDLE) || + !ENCRYPTION_STATUS_GET() || + BONDING_IN_PROGRESS_STATUS_GET() + ) + { + err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0); + } + else + { + // Current central is valid, use its data. Set the corresponding sys_attr. + err_code = central_sys_attr_set(&m_central); + if (err_code == NRF_SUCCESS) + { + // Set System Attributes loaded status variable. + m_sys_attr_loaded = true; + } + } + + if (err_code != NRF_SUCCESS) + { + m_bondmngr_config.error_handler(err_code); + } +} + + +/**@brief Function for handling the new authentication status event, received from the + * SoftDevice, related to an already bonded central. + * + * @details This function also writes the updated Bonding Information to flash and notifies the + * application. + * + * @param[in] p_auth_status Updated authentication status. + */ +static void auth_status_update(ble_gap_evt_auth_status_t * p_auth_status) +{ + uint32_t err_code; + + // Authentication status changed, update Bonding Information. + m_central.bond.auth_status = *p_auth_status; + m_central.bond.central_id_info.div = p_auth_status->periph_keys.enc_info.div; + + memset(&(m_centrals_db[m_central.bond.central_handle]), 0, sizeof(central_t)); + m_centrals_db[m_central.bond.central_handle] = m_central; + + // Write updated Bonding Information to flash. + err_code = bond_info_store(&m_central.bond); + if ((err_code == NRF_ERROR_NO_MEM) && (m_bondmngr_config.evt_handler != NULL)) + { + ble_bondmngr_evt_t evt; + + evt.evt_type = BLE_BONDMNGR_EVT_BOND_FLASH_FULL; + evt.central_handle = m_central.bond.central_handle; + evt.central_id = m_central.bond.central_id_info.div; + + m_bondmngr_config.evt_handler(&evt); + } + else if (err_code != NRF_SUCCESS) + { + m_bondmngr_config.error_handler(err_code); + } + + // Pass the event to the application. + if (m_bondmngr_config.evt_handler != NULL) + { + ble_bondmngr_evt_t evt; + + evt.evt_type = BLE_BONDMNGR_EVT_AUTH_STATUS_UPDATED; + evt.central_handle = m_central.bond.central_handle; + evt.central_id = m_central.bond.central_id_info.div; + + m_bondmngr_config.evt_handler(&evt); + } +} + + +/**@brief Function for handling the Authentication Status event received from the BLE stack. + * + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_auth_status(ble_gap_evt_auth_status_t * p_auth_status) +{ + if (p_auth_status->auth_status != BLE_GAP_SEC_STATUS_SUCCESS) + { + return; + } + + // Verify if its pairing and not bonding + if (!ENCRYPTION_STATUS_GET()) + { + return; + } + + if (m_central.bond.central_handle == INVALID_CENTRAL_HANDLE) + { + uint32_t err_code = central_find_in_db(p_auth_status->periph_keys.enc_info.div); + + if (err_code == NRF_SUCCESS) + { + // Possible DIV Collision indicate error to application, + // not storing the new LTK + err_code = NRF_ERROR_FORBIDDEN; + } + else + { + // Add the new device to data base + err_code = on_auth_status_from_new_central(p_auth_status); + } + + if (err_code != NRF_SUCCESS) + { + m_bondmngr_config.error_handler(err_code); + } + } + else + { + m_bond_loaded = true; + + // Receiving a auth status again when already in have existing information! + auth_status_update(p_auth_status); + } +} + + +/**@brief Function for handling the Security Info Request event received from the BLE stack. + * + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_sec_info_request(ble_evt_t * p_ble_evt) +{ + uint32_t err_code; + + err_code = central_find_in_db(p_ble_evt->evt.gap_evt.params.sec_info_request.div); + if (err_code == NRF_SUCCESS) + { + // Bond information has been found and loaded for security procedures. Reflect this in the + // status variable + m_bond_loaded = true; + + // Central found in the list of bonded central. Use the encryption info for this central. + err_code = sd_ble_gap_sec_info_reply(m_conn_handle, + &m_central.bond.auth_status.periph_keys.enc_info, + NULL); + if (err_code != NRF_SUCCESS) + { + m_bondmngr_config.error_handler(err_code); + } + + // Do not set the sys_attr yet, should be set only when sec_update is successful. + } + else if (err_code == NRF_ERROR_NOT_FOUND) + { + m_central.bond.central_id_info = p_ble_evt->evt.gap_evt.params.sec_info_request; + + // New central. + err_code = sd_ble_gap_sec_info_reply(m_conn_handle, NULL, NULL); + if (err_code != NRF_SUCCESS) + { + m_bondmngr_config.error_handler(err_code); + } + + // Initialize the sys_attr. + err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0); + } + + if (err_code != NRF_SUCCESS) + { + m_bondmngr_config.error_handler(err_code); + } +} + + +/**@brief Function for handling the Connection Security Update event received from the BLE + * stack. + * + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_sec_update(ble_gap_evt_conn_sec_update_t * p_sec_update) +{ + uint8_t security_mode = p_sec_update->conn_sec.sec_mode.sm; + uint8_t security_level = p_sec_update->conn_sec.sec_mode.lv; + + if (((security_mode == 1) && (security_level > 1)) || + ((security_mode == 2) && (security_level != 0))) + { + ENCRYPTION_STATUS_SET(); + + uint32_t err_code = central_sys_attr_set(&m_central); + + if (err_code != NRF_SUCCESS) + { + m_bondmngr_config.error_handler(err_code); + } + else + { + m_sys_attr_loaded = true; + } + + if (m_bondmngr_config.evt_handler != NULL) + { + ble_bondmngr_evt_t evt; + + evt.evt_type = BLE_BONDMNGR_EVT_ENCRYPTED; + evt.central_handle = m_central.bond.central_handle; + evt.central_id = m_central.bond.central_id_info.div; + + m_bondmngr_config.evt_handler(&evt); + } + } +} + + +/**@brief Function for handling the Connection Security Parameters Request event received from + * the BLE stack. + * + * @param[in] p_ble_evt Event received from the BLE stack. + */ +static void on_sec_param_request(ble_gap_evt_sec_params_request_t * p_sec_update) +{ + if (p_sec_update->peer_params.bond) + { + BONDING_IN_PROGRESS_STATUS_SET(); + + if (m_central.bond.central_handle != INVALID_CENTRAL_HANDLE) + { + // Bonding request received from a bonded central, make all system attributes null + m_central.sys_attr.sys_attr_size = 0; + memset(m_central.sys_attr.sys_attr, 0, SYS_ATTR_BUFFER_MAX_LEN); + } + } +} + + +void ble_bondmngr_on_ble_evt(ble_evt_t * p_ble_evt) +{ + if (!m_is_bondmngr_initialized) + { + m_bondmngr_config.error_handler(NRF_ERROR_INVALID_STATE); + } + + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + on_connect(p_ble_evt); + break; + + // NOTE: All actions to be taken on the Disconnected event are performed in + // ble_bondmngr_bonded_centrals_store(). This function must be called from the + // Disconnected handler of the application before advertising is restarted (to make + // sure the flash blocks are cleared while the radio is inactive). + case BLE_GAP_EVT_DISCONNECTED: + SECURITY_STATUS_RESET(); + break; + + case BLE_GATTS_EVT_SYS_ATTR_MISSING: + on_sys_attr_missing(p_ble_evt); + break; + + case BLE_GAP_EVT_AUTH_STATUS: + on_auth_status(&p_ble_evt->evt.gap_evt.params.auth_status); + break; + + case BLE_GAP_EVT_SEC_INFO_REQUEST: + on_sec_info_request(p_ble_evt); + break; + + case BLE_GAP_EVT_SEC_PARAMS_REQUEST: + on_sec_param_request(&p_ble_evt->evt.gap_evt.params.sec_params_request); + break; + + case BLE_GAP_EVT_CONN_SEC_UPDATE: + on_sec_update(&p_ble_evt->evt.gap_evt.params.conn_sec_update); + break; + + default: + // No implementation needed. + break; + } +} + + +uint32_t ble_bondmngr_bonded_centrals_store(void) +{ + uint32_t err_code; + int i; + + VERIFY_MODULE_INITIALIZED(); + + if (m_central.bond.central_handle != INVALID_CENTRAL_HANDLE) + { + // Fetch System Attributes from stack. + uint16_t sys_attr_size = SYS_ATTR_BUFFER_MAX_LEN; + + err_code = sd_ble_gatts_sys_attr_get(m_conn_handle, + m_central.sys_attr.sys_attr, + &sys_attr_size); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_central.sys_attr.central_handle = m_central.bond.central_handle; + m_central.sys_attr.sys_attr_size = (uint16_t)sys_attr_size; + + // Update the current central. + err_code = central_update(); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + // Save Bonding Information if changed. + if (bond_info_changed()) + { + // Erase flash page. + err_code = pstorage_clear(&mp_flash_bond_info,MAX_BONDS_IN_FLASH); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Store bond information for all centrals. + m_bond_info_in_flash_count = 0; + for (i = 0; i < m_centrals_in_db_count; i++) + { + err_code = bond_info_store(&m_centrals_db[i].bond); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + } + + // Save System Attributes, if changed. + if (sys_attr_changed()) + { + // Erase flash page. + err_code = pstorage_clear(&mp_flash_sys_attr, MAX_BONDS_IN_FLASH); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + // Store System Attributes for all centrals. + m_sys_attr_in_flash_count = 0; + for (i = 0; i < m_centrals_in_db_count; i++) + { + err_code = sys_attr_store(&m_centrals_db[i].sys_attr); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + } + + m_conn_handle = BLE_CONN_HANDLE_INVALID; + m_central.bond.central_handle = INVALID_CENTRAL_HANDLE; + m_central.sys_attr.central_handle = INVALID_CENTRAL_HANDLE; + m_central.sys_attr.sys_attr_size = 0; + m_bond_loaded = false; + m_sys_attr_loaded = false; + + return NRF_SUCCESS; +} + + +uint32_t ble_bondmngr_sys_attr_store(void) +{ + uint32_t err_code; + + if (m_central.sys_attr.sys_attr_size == 0) + { + // Connected to new central. So the flash block for System Attributes for this + // central is empty. Hence no erase is needed. + + uint16_t sys_attr_size = SYS_ATTR_BUFFER_MAX_LEN; + + // Fetch System Attributes from stack. + err_code = sd_ble_gatts_sys_attr_get(m_conn_handle, + m_central.sys_attr.sys_attr, + &sys_attr_size); + + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_central.sys_attr.central_handle = m_central.bond.central_handle; + m_central.sys_attr.sys_attr_size = (uint16_t)sys_attr_size; + + // Copy the System Attributes to database. + m_centrals_db[m_central.bond.central_handle].sys_attr = m_central.sys_attr; + + // Write new central's System Attributes to flash. + return (sys_attr_store(&m_central.sys_attr)); + } + else + { + // Will not write to flash because System Attributes of an old central would already be + // in flash and so this operation needs a flash erase operation. + return NRF_ERROR_INVALID_STATE; + } +} + + +uint32_t ble_bondmngr_bonded_centrals_delete(void) +{ + VERIFY_MODULE_INITIALIZED(); + + m_centrals_in_db_count = 0; + m_bond_info_in_flash_count = 0; + m_sys_attr_in_flash_count = 0; + + return flash_pages_erase(); +} + + +uint32_t ble_bondmngr_central_addr_get(int8_t central_handle, ble_gap_addr_t * p_central_addr) +{ + if ( + (central_handle == INVALID_CENTRAL_HANDLE) || + (central_handle >= m_centrals_in_db_count) || + (p_central_addr == NULL) || + ( + m_centrals_db[central_handle].bond.central_addr.addr_type + == + BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE + ) + ) + { + return NRF_ERROR_INVALID_PARAM; + } + + *p_central_addr = m_centrals_db[central_handle].bond.central_addr; + return NRF_SUCCESS; +} + + +uint32_t ble_bondmngr_whitelist_get(ble_gap_whitelist_t * p_whitelist) +{ + static ble_gap_addr_t * s_addr[MAX_NUM_CENTRAL_WHITE_LIST]; + static ble_gap_irk_t * s_irk[MAX_NUM_CENTRAL_WHITE_LIST]; + + int i; + + for (i = 0; i < m_irk_count; i++) + { + s_irk[i] = m_whitelist_irk[i].p_irk; + } + for (i = 0; i < m_addr_count; i++) + { + s_addr[i] = m_whitelist_addr[i].p_addr; + } + + p_whitelist->addr_count = m_addr_count; + p_whitelist->pp_addrs = (m_addr_count != 0) ? s_addr : NULL; + p_whitelist->irk_count = m_irk_count; + p_whitelist->pp_irks = (m_irk_count != 0) ? s_irk : NULL; + + return NRF_SUCCESS; +} + + +static void bm_pstorage_cb_handler(pstorage_handle_t * handle, + uint8_t op_code, + uint32_t result, + uint8_t * p_data, + uint32_t data_len) +{ + if (result != NRF_SUCCESS) + { + m_bondmngr_config.error_handler(result); + } +} + + +uint32_t ble_bondmngr_init(ble_bondmngr_init_t * p_init) +{ + pstorage_module_param_t param; + uint32_t err_code; + + if (p_init->error_handler == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + if (BLE_BONDMNGR_MAX_BONDED_CENTRALS > MAX_BONDS_IN_FLASH) + { + return NRF_ERROR_DATA_SIZE; + } + + param.block_size = sizeof (central_bond_t) + sizeof (uint32_t); + param.block_count = MAX_BONDS_IN_FLASH; + param.cb = bm_pstorage_cb_handler; + + // Blocks are requested twice, once for bond information and once for system attributes. + // The number of blocks requested has to be the maximum number of bonded devices that + // need to be supported. However, the size of blocks can be different if the sizes of + // system attributes and bonds are not too close. + err_code = pstorage_register(¶m, &mp_flash_bond_info); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + param.block_size = sizeof(central_sys_attr_t) + sizeof(uint32_t); + + err_code = pstorage_register(¶m, &mp_flash_sys_attr); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_bondmngr_config = *p_init; + + memset(&m_central, 0, sizeof(central_t)); + + m_central.bond.central_handle = INVALID_CENTRAL_HANDLE; + m_conn_handle = BLE_CONN_HANDLE_INVALID; + m_centrals_in_db_count = 0; + m_bond_info_in_flash_count = 0; + m_sys_attr_in_flash_count = 0; + + SECURITY_STATUS_RESET(); + + // Erase all stored centrals if specified. + if (m_bondmngr_config.bonds_delete) + { + err_code = flash_pages_erase(); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_centrals_in_db_count = 0; + int i; + for (i = m_centrals_in_db_count; i < BLE_BONDMNGR_MAX_BONDED_CENTRALS; i++) + { + m_centrals_db[i].bond.central_handle = INVALID_CENTRAL_HANDLE; + m_centrals_db[i].sys_attr.sys_attr_size = 0; + m_centrals_db[i].sys_attr.central_handle = INVALID_CENTRAL_HANDLE; + } + } + else + { + // Load bond manager data from flash. + err_code = load_all_from_flash(); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + m_is_bondmngr_initialized = true; + + return NRF_SUCCESS; +} + + +uint32_t ble_bondmngr_central_ids_get(uint16_t * p_central_ids, uint16_t * p_length) +{ + VERIFY_MODULE_INITIALIZED(); + int i; + if (p_length == NULL) + { + return NRF_ERROR_NULL; + } + + if (*p_length < m_centrals_in_db_count) + { + // Length of the input array is not enough to fit all known central identifiers. + return NRF_ERROR_DATA_SIZE; + } + + *p_length = m_centrals_in_db_count; + if (p_central_ids == NULL) + { + // Only the length field was required to be filled. + return NRF_SUCCESS; + } + + for (i = 0; i < m_centrals_in_db_count; i++) + { + p_central_ids[i] = m_centrals_db[i].bond.central_id_info.div; + } + + return NRF_SUCCESS; +} + + +uint32_t ble_bondmngr_bonded_central_delete(uint16_t central_id) +{ + VERIFY_MODULE_INITIALIZED(); + + int8_t central_handle_to_be_deleted = INVALID_CENTRAL_HANDLE; + uint8_t i; + + // Search for the handle of the central. + for (i = 0; i < m_centrals_in_db_count; i++) + { + if (m_centrals_db[i].bond.central_id_info.div == central_id) + { + central_handle_to_be_deleted = i; + break; + } + } + + if (central_handle_to_be_deleted == INVALID_CENTRAL_HANDLE) + { + // Central ID not found. + return NRF_ERROR_NOT_FOUND; + } + + // Delete the central in RAM. + for (i = central_handle_to_be_deleted; i < (m_centrals_in_db_count - 1); i++) + { + // Overwrite the current central entry with the next one. + m_centrals_db[i] = m_centrals_db[i + 1]; + + // Decrement the value of handle. + m_centrals_db[i].bond.central_handle--; + if (INVALID_CENTRAL_HANDLE != m_centrals_db[i].sys_attr.central_handle) + { + m_centrals_db[i].sys_attr.central_handle--; + } + } + + // Clear the last database entry. + memset(&(m_centrals_db[m_centrals_in_db_count - 1]), 0, sizeof(central_t)); + + m_centrals_in_db_count--; + + uint32_t err_code; + + // Reinitialize the pointers to the memory where bonding info and System Attributes are stored + // in flash. + // Refresh the data in the flash memory (both Bonding Information and System Attributes). + // Erase and rewrite bonding info and System Attributes. + + err_code = flash_pages_erase(); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_bond_info_in_flash_count = 0; + m_sys_attr_in_flash_count = 0; + + for (i = 0; i < m_centrals_in_db_count; i++) + { + err_code = bond_info_store(&(m_centrals_db[i].bond)); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + for (i = 0; i < m_centrals_in_db_count; i++) + { + err_code = sys_attr_store(&(m_centrals_db[i].sys_attr)); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + update_whitelist(); + + return NRF_SUCCESS; +} + + +uint32_t ble_bondmngr_is_link_encrypted (bool * status) +{ + VERIFY_MODULE_INITIALIZED(); + + (*status) = ENCRYPTION_STATUS_GET(); + + return NRF_SUCCESS; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_conn_params.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_conn_params.cpp new file mode 100644 index 0000000000..68772fd2a9 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_conn_params.cpp @@ -0,0 +1,322 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include "ble_conn_params.h" +#include +#include "nordic_common.h" +#include "ble_hci.h" +#include "app_timer.h" +#include "ble_srv_common.h" +#include "app_util.h" + + +static ble_conn_params_init_t m_conn_params_config; /**< Configuration as specified by the application. */ +static ble_gap_conn_params_t m_preferred_conn_params; /**< Connection parameters preferred by the application. */ +static uint8_t m_update_count; /**< Number of Connection Parameter Update messages that has currently been sent. */ +static uint16_t m_conn_handle; /**< Current connection handle. */ +static ble_gap_conn_params_t m_current_conn_params; /**< Connection parameters received in the most recent Connect event. */ +static app_timer_id_t m_conn_params_timer_id; /**< Connection parameters timer. */ + +static bool m_change_param = false; + +static bool is_conn_params_ok(ble_gap_conn_params_t * p_conn_params) +{ + // Check if interval is within the acceptable range. + // NOTE: Using max_conn_interval in the received event data because this contains + // the client's connection interval. + if ( + (p_conn_params->max_conn_interval >= m_preferred_conn_params.min_conn_interval) + && + (p_conn_params->max_conn_interval <= m_preferred_conn_params.max_conn_interval) + ) + { + return true; + } + else + { + return false; + } +} + + +static void update_timeout_handler(void * p_context) +{ + UNUSED_PARAMETER(p_context); + + if (m_conn_handle != BLE_CONN_HANDLE_INVALID) + { + // Check if we have reached the maximum number of attempts + m_update_count++; + if (m_update_count <= m_conn_params_config.max_conn_params_update_count) + { + uint32_t err_code; + + // Parameters are not ok, send connection parameters update request. + err_code = sd_ble_gap_conn_param_update(m_conn_handle, &m_preferred_conn_params); + if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL)) + { + m_conn_params_config.error_handler(err_code); + } + } + else + { + m_update_count = 0; + + // Negotiation failed, disconnect automatically if this has been configured + if (m_conn_params_config.disconnect_on_fail) + { + uint32_t err_code; + + err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE); + if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL)) + { + m_conn_params_config.error_handler(err_code); + } + } + + // Notify the application that the procedure has failed + if (m_conn_params_config.evt_handler != NULL) + { + ble_conn_params_evt_t evt; + + evt.evt_type = BLE_CONN_PARAMS_EVT_FAILED; + m_conn_params_config.evt_handler(&evt); + } + } + } +} + + +uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init) +{ + uint32_t err_code; + + m_conn_params_config = *p_init; + m_change_param = false; + if (p_init->p_conn_params != NULL) + { + m_preferred_conn_params = *p_init->p_conn_params; + + // Set the connection params in stack + err_code = sd_ble_gap_ppcp_set(&m_preferred_conn_params); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + else + { + // Fetch the connection params from stack + err_code = sd_ble_gap_ppcp_get(&m_preferred_conn_params); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + } + + m_conn_handle = BLE_CONN_HANDLE_INVALID; + m_update_count = 0; + + return app_timer_create(&m_conn_params_timer_id, + APP_TIMER_MODE_SINGLE_SHOT, + update_timeout_handler); +} + + +uint32_t ble_conn_params_stop(void) +{ + return app_timer_stop(m_conn_params_timer_id); +} + + +static void conn_params_negotiation(void) +{ + // Start negotiation if the received connection parameters are not acceptable + if (!is_conn_params_ok(&m_current_conn_params)) + { + uint32_t err_code; + uint32_t timeout_ticks; + + if (m_change_param) + { + // Notify the application that the procedure has failed + if (m_conn_params_config.evt_handler != NULL) + { + ble_conn_params_evt_t evt; + + evt.evt_type = BLE_CONN_PARAMS_EVT_FAILED; + m_conn_params_config.evt_handler(&evt); + } + } + else + { + if (m_update_count == 0) + { + // First connection parameter update + timeout_ticks = m_conn_params_config.first_conn_params_update_delay; + } + else + { + timeout_ticks = m_conn_params_config.next_conn_params_update_delay; + } + + err_code = app_timer_start(m_conn_params_timer_id, timeout_ticks, NULL); + if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL)) + { + m_conn_params_config.error_handler(err_code); + } + } + } + else + { + // Notify the application that the procedure has succeded + if (m_conn_params_config.evt_handler != NULL) + { + ble_conn_params_evt_t evt; + + evt.evt_type = BLE_CONN_PARAMS_EVT_SUCCEEDED; + m_conn_params_config.evt_handler(&evt); + } + } + m_change_param = false; +} + + +static void on_connect(ble_evt_t * p_ble_evt) +{ + // Save connection parameters + m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + m_current_conn_params = p_ble_evt->evt.gap_evt.params.connected.conn_params; + m_update_count = 0; // Connection parameter negotiation should re-start every connection + + // Check if we shall handle negotiation on connect + if (m_conn_params_config.start_on_notify_cccd_handle == BLE_GATT_HANDLE_INVALID) + { + conn_params_negotiation(); + } +} + + +static void on_disconnect(ble_evt_t * p_ble_evt) +{ + uint32_t err_code; + + m_conn_handle = BLE_CONN_HANDLE_INVALID; + + // Stop timer if running + m_update_count = 0; // Connection parameters updates should happen during every connection + + err_code = app_timer_stop(m_conn_params_timer_id); + if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL)) + { + m_conn_params_config.error_handler(err_code); + } +} + + +static void on_write(ble_evt_t * p_ble_evt) +{ + ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; + + // Check if this the correct CCCD + if ( + (p_evt_write->handle == m_conn_params_config.start_on_notify_cccd_handle) + && + (p_evt_write->len == 2) + ) + { + // Check if this is a 'start notification' + if (ble_srv_is_notification_enabled(p_evt_write->data)) + { + // Do connection parameter negotiation if necessary + conn_params_negotiation(); + } + else + { + uint32_t err_code; + + // Stop timer if running + err_code = app_timer_stop(m_conn_params_timer_id); + if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL)) + { + m_conn_params_config.error_handler(err_code); + } + } + } +} + + +static void on_conn_params_update(ble_evt_t * p_ble_evt) +{ + // Copy the parameters + m_current_conn_params = p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params; + + conn_params_negotiation(); +} + + +void ble_conn_params_on_ble_evt(ble_evt_t * p_ble_evt) +{ + switch (p_ble_evt->header.evt_id) + { + case BLE_GAP_EVT_CONNECTED: + on_connect(p_ble_evt); + break; + + case BLE_GAP_EVT_DISCONNECTED: + on_disconnect(p_ble_evt); + break; + + case BLE_GATTS_EVT_WRITE: + on_write(p_ble_evt); + break; + + case BLE_GAP_EVT_CONN_PARAM_UPDATE: + on_conn_params_update(p_ble_evt); + break; + + default: + // No implementation needed. + break; + } +} + +uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t *new_params) +{ + uint32_t err_code; + + m_preferred_conn_params = *new_params; + // Set the connection params in stack + err_code = sd_ble_gap_ppcp_set(&m_preferred_conn_params); + if (err_code == NRF_SUCCESS) + { + if (!is_conn_params_ok(&m_current_conn_params)) + { + m_change_param = true; + err_code = sd_ble_gap_conn_param_update(m_conn_handle, &m_preferred_conn_params); + m_update_count = 1; + } + else + { + // Notify the application that the procedure has succeded + if (m_conn_params_config.evt_handler != NULL) + { + ble_conn_params_evt_t evt; + + evt.evt_type = BLE_CONN_PARAMS_EVT_SUCCEEDED; + m_conn_params_config.evt_handler(&evt); + } + err_code = NRF_SUCCESS; + } + } + return err_code; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_debug_assert_handler.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_debug_assert_handler.cpp new file mode 100644 index 0000000000..6ccbe33644 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_debug_assert_handler.cpp @@ -0,0 +1,55 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include "ble_debug_assert_handler.h" +#include +#include "nrf51.h" +#include "ble_error_log.h" +#include "nordic_common.h" + +#define MAX_LENGTH_FILENAME 128 /**< Max length of filename to copy for the debug error handlier. */ + + +// WARNING - DO NOT USE THIS FUNCTION IN END PRODUCT. - WARNING +// WARNING - FOR DEBUG PURPOSES ONLY. - WARNING +void ble_debug_assert_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) +{ + // Copying parameters to static variables because parameters may not be accessible in debugger. + static volatile uint8_t s_file_name[MAX_LENGTH_FILENAME]; + static volatile uint16_t s_line_num; + static volatile uint32_t s_error_code; + + strncpy((char *)s_file_name, (const char *)p_file_name, MAX_LENGTH_FILENAME - 1); + s_file_name[MAX_LENGTH_FILENAME - 1] = '\0'; + s_line_num = line_num; + s_error_code = error_code; + UNUSED_VARIABLE(s_file_name); + UNUSED_VARIABLE(s_line_num); + UNUSED_VARIABLE(s_error_code); + + // WARNING: The PRIMASK register is set to disable ALL interrups during writing the error log. + // + // Do not use __disable_irq() in normal operation. + __disable_irq(); + + // This function will write error code, filename, and line number to the flash. + // In addition, the Cortex-M0 stack memory will also be written to the flash. + //(void) ble_error_log_write(error_code, p_file_name, line_num); + + // For debug purposes, this function never returns. + // Attach a debugger for tracing the error cause. + for (;;) + { + // Do nothing. + } +} + diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_error_log.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_error_log.cpp new file mode 100644 index 0000000000..788c5670ec --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_error_log.cpp @@ -0,0 +1,61 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include +#include +#include +#include +#include "ble_error_log.h" +#include "app_util.h" +#include "app_error.h" +#include "nrf_gpio.h" +#include "pstorage.h" + + +// Made static to avoid the error_log to go on the stack. +static ble_error_log_data_t m_ble_error_log; /**< . */ +//lint -esym(526,__Vectors) +extern uint32_t * __Vectors; /**< The initialization vector holds the address to __initial_sp that will be used when fetching the stack. */ + +static void fetch_stack(ble_error_log_data_t * error_log) +{ + // KTOWN: Temporarily removed 06022014 + /* + uint32_t * p_stack; + uint32_t * initial_sp; + uint32_t length; + + initial_sp = (uint32_t *) __Vectors; + p_stack = (uint32_t *) GET_SP(); + + length = ((uint32_t) initial_sp) - ((uint32_t) p_stack); + memcpy(error_log->stack_info, + p_stack, + (length > STACK_DUMP_LENGTH) ? STACK_DUMP_LENGTH : length); + */ +} + +uint32_t ble_error_log_write(uint32_t err_code, const uint8_t * p_message, uint16_t line_number) +{ + m_ble_error_log.failure = true; + m_ble_error_log.err_code = err_code; + m_ble_error_log.line_number = line_number; + + strncpy((char *)m_ble_error_log.message, (const char *)p_message, ERROR_MESSAGE_LENGTH - 1); + m_ble_error_log.message[ERROR_MESSAGE_LENGTH - 1] = '\0'; + + fetch_stack(&m_ble_error_log); + + // Write to flash removed, to be redone. + + return NRF_SUCCESS; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_services/ble_srv_common.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_services/ble_srv_common.cpp new file mode 100644 index 0000000000..84099f11b3 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble/ble_services/ble_srv_common.cpp @@ -0,0 +1,41 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/* Attention! +* To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile +* qualification listings, this section of source code must not be modified. +*/ + +#include "ble_srv_common.h" +#include +#include "nordic_common.h" +#include "app_error.h" + + +uint8_t ble_srv_report_ref_encode(uint8_t * p_encoded_buffer, + const ble_srv_report_ref_t * p_report_ref) +{ + uint8_t len = 0; + + p_encoded_buffer[len++] = p_report_ref->report_id; + p_encoded_buffer[len++] = p_report_ref->report_type; + + APP_ERROR_CHECK_BOOL(len == BLE_SRV_ENCODED_REPORT_REF_LEN); + return len; +} + + +void ble_srv_ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, char * p_ascii) +{ + p_utf8->length = (uint16_t)strlen(p_ascii); + p_utf8->p_str = (uint8_t *)p_ascii; +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble_bondmngr_cfg.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble_bondmngr_cfg.h new file mode 100644 index 0000000000..55e73dc574 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/ble_bondmngr_cfg.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + + /** @cond To make doxygen skip this file */ + +/** @file + * + * @defgroup ble_sdk_app_gls_bondmngr_cfg GLS Bond Manager Configuration + * @{ + * @ingroup ble_sdk_app_gls + * @brief Definition of bond manager configurable parameters + */ + +#ifndef BLE_BONDMNGR_CFG_H__ +#define BLE_BONDMNGR_CFG_H__ + +/**@brief Number of CCCDs used in the GLS application. */ +#define BLE_BONDMNGR_CCCD_COUNT 2 + +/**@brief Maximum number of bonded centrals. */ +#define BLE_BONDMNGR_MAX_BONDED_CENTRALS 7 + +#endif // BLE_BONDMNGR_CFG_H__ + +/** @} */ +/** @endcond */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nordic_global.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nordic_global.h new file mode 100644 index 0000000000..70ece25463 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nordic_global.h @@ -0,0 +1,11 @@ +#ifndef _NORDIC_GLOBAL_H_ +#define _NORDIC_GLOBAL_H_ + +/* There are no global defines in mbed, so we need to define */ +/* mandatory conditional compilation flags here */ +#define NRF51 +#define DEBUG_NRF_USER +#define BLE_STACK_SUPPORT_REQD +#define BOARD_PCA10001 + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_button.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_button.h new file mode 100644 index 0000000000..29a00e218a --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_button.h @@ -0,0 +1,174 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup app_button Button Handler + * @{ + * @ingroup app_common + * + * @brief Buttons handling module. + * + * @details The button handler uses the @ref app_gpiote to detect that a button has been + * pushed. To handle debouncing, it will start a timer in the GPIOTE event handler. + * The button will only be reported as pushed if the corresponding pin is still active when + * the timer expires. If there is a new GPIOTE event while the timer is running, the timer + * is restarted. + * Use the USE_SCHEDULER parameter of the APP_BUTTON_INIT() macro to select if the + * @ref app_scheduler is to be used or not. + * + * @note The app_button module uses the app_timer module. The user must ensure that the queue in + * app_timer is large enough to hold the app_timer_stop() / app_timer_start() operations + * which will be executed on each event from GPIOTE module (2 operations), as well as other + * app_timer operations queued simultaneously in the application. + * + * @note Even if the scheduler is not used, app_button.h will include app_scheduler.h, so when + * compiling, app_scheduler.h must be available in one of the compiler include paths. + */ + +#ifndef APP_BUTTON_H__ +#define APP_BUTTON_H__ + +#include +#include +#include "nordic_global.h" +#include "nrf.h" +#include "app_error.h" +#include "app_scheduler.h" +#include "nrf_gpio.h" + +#define APP_BUTTON_SCHED_EVT_SIZE sizeof(app_button_event_t) /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). */ + +/**@brief Button event handler type. */ +typedef void (*app_button_handler_t)(uint8_t pin_no); + +/**@brief Type of function for passing events from the Button Handler module to the scheduler. */ +typedef uint32_t (*app_button_evt_schedule_func_t) (app_button_handler_t button_handler, + uint8_t pin_no); + +/**@brief Button configuration structure. */ +typedef struct +{ + uint8_t pin_no; /**< Pin to be used as a button. */ + bool active_high; /**< TRUE if pin is active high, FALSE otherwise. */ + nrf_gpio_pin_pull_t pull_cfg; /**< Pull-up or -down configuration. */ + app_button_handler_t button_handler; /**< Handler to be called when button is pushed. */ +} app_button_cfg_t; + +/**@brief Macro for initializing the Button Handler module. + * + * @details It will initialize the specified pins as buttons, and configure the Button Handler + * module as a GPIOTE user (but it will not enable button detection). It will also connect + * the Button Handler module to the scheduler (if specified). + * + * @param[in] BUTTONS Array of buttons to be used (type app_button_cfg_t, must be + * static!). + * @param[in] BUTTON_COUNT Number of buttons. + * @param[in] DETECTION_DELAY Delay from a GPIOTE event until a button is reported as pushed. + * @param[in] USE_SCHEDULER TRUE if the application is using the event scheduler, + * FALSE otherwise. + */ +/*lint -emacro(506, APP_BUTTON_INIT) */ /* Suppress "Constant value Boolean */ +#define APP_BUTTON_INIT(BUTTONS, BUTTON_COUNT, DETECTION_DELAY, USE_SCHEDULER) \ + do \ + { \ + uint32_t ERR_CODE = app_button_init((BUTTONS), \ + (BUTTON_COUNT), \ + (DETECTION_DELAY), \ + (USE_SCHEDULER) ? app_button_evt_schedule : NULL); \ + APP_ERROR_CHECK(ERR_CODE); \ + } while (0) + +/**@brief Function for initializing the Buttons. + * + * @details This function will initialize the specified pins as buttons, and configure the Button + * Handler module as a GPIOTE user (but it will not enable button detection). + * + * @note Normally initialization should be done using the APP_BUTTON_INIT() macro, as that will take + * care of connecting the Buttons module to the scheduler (if specified). + * + * @note app_button_enable() function must be called in order to enable the button detection. + * + * @param[in] p_buttons Array of buttons to be used (NOTE: Must be static!). + * @param[in] button_count Number of buttons. + * @param[in] detection_delay Delay from a GPIOTE event until a button is reported as pushed. + * @param[in] evt_schedule_func Function for passing button events to the scheduler. Point to + * app_button_evt_schedule() to connect to the scheduler. Set to + * NULL to make the Buttons module call the event handler directly + * from the delayed button push detection timeout handler. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +uint32_t app_button_init(app_button_cfg_t * p_buttons, + uint8_t button_count, + uint32_t detection_delay, + app_button_evt_schedule_func_t evt_schedule_func); + +/**@brief Function for enabling button detection. + * + * @retval NRF_ERROR_INVALID_PARAM GPIOTE has to many users. + * @retval NRF_ERROR_INVALID_STATE Button or GPIOTE not initialized. + * @retval NRF_SUCCESS Button detection successfully enabled. + */ +uint32_t app_button_enable(void); + +/**@brief Function for disabling button detection. + * + * @retval NRF_ERROR_INVALID_PARAM GPIOTE has to many users. + * @retval NRF_ERROR_INVALID_STATE Button or GPIOTE not initialized. + * @retval NRF_SUCCESS Button detection successfully enabled. + */ +uint32_t app_button_disable(void); + +/**@brief Function for checking if a button is currently being pushed. + * + * @param[in] pin_no Button pin to be checked. + * @param[out] p_is_pushed Button state. + * + * @retval NRF_SUCCESS State successfully read. + * @retval NRF_ERROR_INVALID_PARAM Invalid pin_no. + */ +uint32_t app_button_is_pushed(uint8_t pin_no, bool * p_is_pushed); + + +// Type and functions for connecting the Buttons module to the scheduler: + +/**@cond NO_DOXYGEN */ +typedef struct +{ + app_button_handler_t button_handler; + uint8_t pin_no; +} app_button_event_t; + +static __INLINE void app_button_evt_get(void * p_event_data, uint16_t event_size) +{ + app_button_event_t * p_buttons_event = (app_button_event_t *)p_event_data; + + APP_ERROR_CHECK_BOOL(event_size == sizeof(app_button_event_t)); + p_buttons_event->button_handler(p_buttons_event->pin_no); +} + +static __INLINE uint32_t app_button_evt_schedule(app_button_handler_t button_handler, + uint8_t pin_no) +{ + app_button_event_t buttons_event; + + buttons_event.button_handler = button_handler; + buttons_event.pin_no = pin_no; + + return app_sched_event_put(&buttons_event, sizeof(buttons_event), app_button_evt_get); +} +/**@endcond */ + +#endif // APP_BUTTON_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_error.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_error.h new file mode 100644 index 0000000000..43fdf66019 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_error.h @@ -0,0 +1,78 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup app_error Common application error handler + * @{ + * @ingroup app_common + * + * @brief Common application error handler and macros for utilizing a common error handler. + */ + +#ifndef APP_ERROR_H__ +#define APP_ERROR_H__ + +#include +#include +#include "nordic_global.h" +#include "nrf_error.h" + +/**@brief Function for error handling, which is called when an error has occurred. + * + * @param[in] error_code Error code supplied to the handler. + * @param[in] line_num Line number where the handler is called. + * @param[in] p_file_name Pointer to the file name. + */ +void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); + +/**@brief Macro for calling error handler function. + * + * @param[in] ERR_CODE Error code supplied to the error handler. + */ +#define APP_ERROR_HANDLER(ERR_CODE) \ + do \ + { \ + app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__); \ + } while (0) + +/**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS. + * + * @param[in] ERR_CODE Error code supplied to the error handler. + */ +#define APP_ERROR_CHECK(ERR_CODE) \ + do \ + { \ + const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \ + if (LOCAL_ERR_CODE != NRF_SUCCESS) \ + { \ + APP_ERROR_HANDLER(LOCAL_ERR_CODE); \ + } \ + } while (0) + +/**@brief Macro for calling error handler function if supplied boolean value is false. + * + * @param[in] BOOLEAN_VALUE Boolean value to be evaluated. + */ +#define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE) \ + do \ + { \ + const bool LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \ + if (!LOCAL_BOOLEAN_VALUE) \ + { \ + APP_ERROR_HANDLER(0); \ + } \ + } while (0) + +#endif // APP_ERROR_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_fifo.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_fifo.h new file mode 100644 index 0000000000..10640e5e1b --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_fifo.h @@ -0,0 +1,84 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/**@file + * + * @defgroup app_fifo FIFO implementation + * @{ + * @ingroup app_common + * + * @brief FIFO implementation. + */ + +#ifndef APP_FIFO_H__ +#define APP_FIFO_H__ + +#include +#include +#include "nordic_global.h" +#include "nrf_error.h" + +/**@brief A FIFO instance structure. Keeps track of which bytes to read and write next. + * Also it keeps the information about which memory is allocated for the buffer + * and its size. This needs to be initialized by app_fifo_init() before use. + */ +typedef struct +{ + uint8_t * p_buf; /**< Pointer to FIFO buffer memory. */ + uint16_t buf_size_mask; /**< Read/write index mask. Also used for size checking. */ + volatile uint32_t read_pos; /**< Next read position in the FIFO buffer. */ + volatile uint32_t write_pos; /**< Next write position in the FIFO buffer. */ +} app_fifo_t; + +/**@brief Function for initializing the FIFO. + * + * @param[out] p_fifo FIFO object. + * @param[in] p_buf FIFO buffer for storing data. The buffer size has to be a power of two. + * @param[in] buf_size Size of the FIFO buffer provided, has to be a power of 2. + * + * @retval NRF_SUCCESS If initialization was successful. + * @retval NRF_ERROR_NULL If a NULL pointer is provided as buffer. + * @retval NRF_ERROR_INVALID_LENGTH If size of buffer provided is not a power of two. + */ +uint32_t app_fifo_init(app_fifo_t * p_fifo, uint8_t * p_buf, uint16_t buf_size); + +/**@brief Function for adding an element to the FIFO. + * + * @param[in] p_fifo Pointer to the FIFO. + * @param[in] byte Data byte to add to the FIFO. + * + * @retval NRF_SUCCESS If an element has been successfully added to the FIFO. + * @retval NRF_ERROR_NO_MEM If the FIFO is full. + */ +uint32_t app_fifo_put(app_fifo_t * p_fifo, uint8_t byte); + +/**@brief Function for getting the next element from the FIFO. + * + * @param[in] p_fifo Pointer to the FIFO. + * @param[out] p_byte Byte fetched from the FIFO. + * + * @retval NRF_SUCCESS If an element was returned. + * @retval NRF_ERROR_NOT_FOUND If there is no more elements in the queue. + */ +uint32_t app_fifo_get(app_fifo_t * p_fifo, uint8_t * p_byte); + +/**@brief Function for flushing the FIFO. + * + * @param[in] p_fifo Pointer to the FIFO. + * + * @retval NRF_SUCCESS If the FIFO flushed successfully. + */ +uint32_t app_fifo_flush(app_fifo_t * p_fifo); + +#endif // APP_FIFO_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_gpiote.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_gpiote.h new file mode 100644 index 0000000000..6fab8b2f65 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_gpiote.h @@ -0,0 +1,161 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup app_gpiote GPIOTE Handler + * @{ + * @ingroup app_common + * + * @brief GPIOTE handler module. + * + * @details The GPIOTE handler allows several modules ("users") to share the GPIOTE interrupt, + * each user defining a set of pins able to generate events to the user. + * When a GPIOTE interrupt occurs, the GPIOTE interrupt handler will call the event handler + * of each user for which at least one of the pins generated an event. + * + * The GPIOTE users are responsible for configuring all their corresponding pins, except + * the SENSE field, which should be initialized to GPIO_PIN_CNF_SENSE_Disabled. + * The SENSE field will be updated by the GPIOTE module when it is enabled or disabled, + * and also while it is enabled. + * + * The module specifies on which pins events should be generated if the pin(s) goes + * from low->high or high->low or both directions. + * + * @note Even if the application is using the @ref app_scheduler, the GPIOTE event handlers will + * be called directly from the GPIOTE interrupt handler. + */ + +#ifndef APP_GPIOTE_H__ +#define APP_GPIOTE_H__ + +#include +#include +#include "nordic_global.h" +#include "nrf.h" +#include "app_error.h" +#include "app_util.h" + +#define GPIOTE_USER_NODE_SIZE 20 /**< Size of app_gpiote.gpiote_user_t (only for use inside APP_GPIOTE_BUF_SIZE()). */ +#define NO_OF_PINS 32 /**< Number of GPIO pins on the nRF51 chip. */ + +/**@brief Compute number of bytes required to hold the GPIOTE data structures. + * + * @param[in] MAX_USERS Maximum number of GPIOTE users. + * + * @return Required buffer size (in bytes). + */ +#define APP_GPIOTE_BUF_SIZE(MAX_USERS) ((MAX_USERS) * GPIOTE_USER_NODE_SIZE) + +typedef uint8_t app_gpiote_user_id_t; + +/**@brief GPIOTE event handler type. */ +typedef void (*app_gpiote_event_handler_t)(uint32_t event_pins_low_to_high, + uint32_t event_pins_high_to_low); + +/**@brief Macro for initializing the GPIOTE module. + * + * @details It will handle dimensioning and allocation of the memory buffer required by the module, + * making sure that the buffer is correctly aligned. + * + * @param[in] MAX_USERS Maximum number of GPIOTE users. + * + * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it + * several times as long as it is from the same location, e.g. to do a reinitialization). + */ +/*lint -emacro(506, APP_GPIOTE_INIT) */ /* Suppress "Constant value Boolean */ +#define APP_GPIOTE_INIT(MAX_USERS) \ + do \ + { \ + static uint32_t app_gpiote_buf[CEIL_DIV(APP_GPIOTE_BUF_SIZE(MAX_USERS), sizeof(uint32_t))];\ + uint32_t ERR_CODE = app_gpiote_init((MAX_USERS), app_gpiote_buf); \ + APP_ERROR_CHECK(ERR_CODE); \ + } while (0) + +/**@brief Function for initializing the GPIOTE module. + * + * @note Normally initialization should be done using the APP_GPIOTE_INIT() macro, as that will + * allocate the buffer needed by the GPIOTE module (including aligning the buffer correctly). + * + * @param[in] max_users Maximum number of GPIOTE users. + * @param[in] p_buffer Pointer to memory buffer for internal use in the app_gpiote + * module. The size of the buffer can be computed using the + * APP_GPIOTE_BUF_SIZE() macro. The buffer must be aligned to + * a 4 byte boundary. + * + * @retval NRF_SUCCESS Successful initialization. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte + * boundary). + */ +uint32_t app_gpiote_init(uint8_t max_users, void * p_buffer); + +/**@brief Function for registering a GPIOTE user. + * + * @param[out] p_user_id Id for the new GPIOTE user. + * @param[in] pins_low_to_high_mask Mask defining which pins will generate events to this user + * when state is changed from low->high. + * @param[in] pins_high_to_low_mask Mask defining which pins will generate events to this user + * when state is changed from high->low. + * @param[in] event_handler Pointer to function to be executed when an event occurs. + * + * @retval NRF_SUCCESS Successful initialization. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte boundary). + * @retval NRF_ERROR_INALID_STATE If @ref app_gpiote_init has not been called on the GPIOTE + * module. + * @retval NRF_ERROR_NO_MEM Returned if the application tries to register more users + * than defined when the GPIOTE module was initialized in + * @ref app_gpiote_init. + */ +uint32_t app_gpiote_user_register(app_gpiote_user_id_t * p_user_id, + uint32_t pins_low_to_high_mask, + uint32_t pins_high_to_low_mask, + app_gpiote_event_handler_t event_handler); + +/**@brief Function for informing the GPIOTE module that the specified user wants to use the GPIOTE module. + * + * @param[in] user_id Id of user to enable. + * + * @retval NRF_SUCCESS On success. + * @retval NRF_ERROR_INVALID_PARAM Invalid user_id provided, No a valid user. + * @retval NRF_ERROR_INALID_STATE If @ref app_gpiote_init has not been called on the GPIOTE + * module. + */ +uint32_t app_gpiote_user_enable(app_gpiote_user_id_t user_id); + +/**@brief Function for informing the GPIOTE module that the specified user is done using the GPIOTE module. + * + * @param[in] user_id Id of user to enable. + * + * @return NRF_SUCCESS On success. + * @retval NRF_ERROR_INVALID_PARAM Invalid user_id provided, No a valid user. + * @retval NRF_ERROR_INALID_STATE If @ref app_gpiote_init has not been called on the GPIOTE + * module. + */ +uint32_t app_gpiote_user_disable(app_gpiote_user_id_t user_id); + +/**@brief Function for getting the state of the pins which are registered for the specified user. + * + * @param[in] user_id Id of user to check. + * @param[out] p_pins Bit mask corresponding to the pins configured to generate events to + * the specified user. All bits corresponding to pins in the state + * 'high' will have value '1', all others will have value '0'. + * + * @return NRF_SUCCESS On success. + * @retval NRF_ERROR_INVALID_PARAM Invalid user_id provided, No a valid user. + * @retval NRF_ERROR_INALID_STATE If @ref app_gpiote_init has not been called on the GPIOTE + * module. + */ +uint32_t app_gpiote_pins_state_get(app_gpiote_user_id_t user_id, uint32_t * p_pins); + +#endif // APP_GPIOTE_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_scheduler.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_scheduler.h new file mode 100644 index 0000000000..4b737d48f2 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_scheduler.h @@ -0,0 +1,135 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup app_scheduler Scheduler + * @{ + * @ingroup app_common + * + * @brief The scheduler is used for transferring execution from the interrupt context to the main + * context. + * + * @details See @ref ble_sdk_apps_seq_diagrams for sequence diagrams illustrating the flow of events + * when using the Scheduler. + * + * @section app_scheduler_req Requirements: + * + * @subsection main_context_logic Logic in main context: + * + * - Define an event handler for each type of event expected. + * - Initialize the scheduler by calling the APP_SCHED_INIT() macro before entering the + * application main loop. + * - Call app_sched_execute() from the main loop each time the application wakes up because of an + * event (typically when sd_app_evt_wait() returns). + * + * @subsection int_context_logic Logic in interrupt context: + * + * - In the interrupt handler, call app_sched_event_put() + * with the appropriate data and event handler. This will insert an event into the + * scheduler's queue. The app_sched_execute() function will pull this event and call its + * handler in the main context. + * + * For an example usage of the scheduler, please see the implementations of + * @ref ble_sdk_app_hids_mouse and @ref ble_sdk_app_hids_keyboard. + * + * @image html scheduler_working.jpg The high level design of the scheduler + */ + +#ifndef APP_SCHEDULER_H__ +#define APP_SCHEDULER_H__ + +#include +#include "nordic_global.h" +#include "app_error.h" + +#define APP_SCHED_EVENT_HEADER_SIZE 8 /**< Size of app_scheduler.event_header_t (only for use inside APP_SCHED_BUF_SIZE()). */ + +/**@brief Compute number of bytes required to hold the scheduler buffer. + * + * @param[in] EVENT_SIZE Maximum size of events to be passed through the scheduler. + * @param[in] QUEUE_SIZE Number of entries in scheduler queue (i.e. the maximum number of events + * that can be scheduled for execution). + * + * @return Required scheduler buffer size (in bytes). + */ +#define APP_SCHED_BUF_SIZE(EVENT_SIZE, QUEUE_SIZE) \ + (((EVENT_SIZE) + APP_SCHED_EVENT_HEADER_SIZE) * ((QUEUE_SIZE) + 1)) + +/**@brief Scheduler event handler type. */ +typedef void (*app_sched_event_handler_t)(void * p_event_data, uint16_t event_size); + +/**@brief Macro for initializing the event scheduler. + * + * @details It will also handle dimensioning and allocation of the memory buffer required by the + * scheduler, making sure the buffer is correctly aligned. + * + * @param[in] EVENT_SIZE Maximum size of events to be passed through the scheduler. + * @param[in] QUEUE_SIZE Number of entries in scheduler queue (i.e. the maximum number of events + * that can be scheduled for execution). + * + * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it + * several times as long as it is from the same location, e.g. to do a reinitialization). + */ +#define APP_SCHED_INIT(EVENT_SIZE, QUEUE_SIZE) \ + do \ + { \ + static uint32_t APP_SCHED_BUF[CEIL_DIV(APP_SCHED_BUF_SIZE((EVENT_SIZE), (QUEUE_SIZE)), \ + sizeof(uint32_t))]; \ + uint32_t ERR_CODE = app_sched_init((EVENT_SIZE), (QUEUE_SIZE), APP_SCHED_BUF); \ + APP_ERROR_CHECK(ERR_CODE); \ + } while (0) + +/**@brief Function for initializing the Scheduler. + * + * @details It must be called before entering the main loop. + * + * @param[in] max_event_size Maximum size of events to be passed through the scheduler. + * @param[in] queue_size Number of entries in scheduler queue (i.e. the maximum number of + * events that can be scheduled for execution). + * @param[in] p_event_buffer Pointer to memory buffer for holding the scheduler queue. It must + * be dimensioned using the APP_SCHED_BUFFER_SIZE() macro. The buffer + * must be aligned to a 4 byte boundary. + * + * @note Normally initialization should be done using the APP_SCHED_INIT() macro, as that will both + * allocate the scheduler buffer, and also align the buffer correctly. + * + * @retval NRF_SUCCESS Successful initialization. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte + * boundary). + */ +uint32_t app_sched_init(uint16_t max_event_size, uint16_t queue_size, void * p_evt_buffer); + +/**@brief Function for executing all scheduled events. + * + * @details This function must be called from within the main loop. It will execute all events + * scheduled since the last time it was called. + */ +void app_sched_execute(void); + +/**@brief Function for scheduling an event. + * + * @details Puts an event into the event queue. + * + * @param[in] p_event_data Pointer to event data to be scheduled. + * @param[in] p_event_size Size of event data to be scheduled. + * @param[in] handler Event handler to receive the event. + * + * @return NRF_SUCCESS on success, otherwise an error code. + */ +uint32_t app_sched_event_put(void * p_event_data, + uint16_t event_size, + app_sched_event_handler_t handler); + +#endif // APP_SCHEDULER_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_timer.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_timer.h new file mode 100644 index 0000000000..8343865577 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_timer.h @@ -0,0 +1,294 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup app_timer Application Timer + * @{ + * @ingroup app_common + * + * @brief Application timer functionality. + * + * @details It enables the application to create multiple timer instances based on the RTC1 + * peripheral. Checking for timeouts and invokation of user timeout handlers is performed + * in the RTC1 interrupt handler. List handling is done using a software interrupt (SWI0). + * Both interrupt handlers are running in APP_LOW priority level. + * + * @note When calling app_timer_start() or app_timer_stop(), the timer operation is just queued, + * and the software interrupt is triggered. The actual timer start/stop operation is + * executed by the SWI0 interrupt handler. Since the SWI0 interrupt is running in APP_LOW, + * if the application code calling the timer function is running in APP_LOW or APP_HIGH, + * the timer operation will not be performed until the application handler has returned. + * This will be the case e.g. when stopping a timer from a timeout handler when not using + * the scheduler. + * + * @details Use the USE_SCHEDULER parameter of the APP_TIMER_INIT() macro to select if the + * @ref app_scheduler is to be used or not. + * + * @note Even if the scheduler is not used, app_timer.h will include app_scheduler.h, so when + * compiling, app_scheduler.h must be available in one of the compiler include paths. + */ + +#ifndef APP_TIMER_H__ +#define APP_TIMER_H__ + +#include +#include +#include +#include "nordic_global.h" +#include "app_error.h" +#include "app_util.h" +#include "app_scheduler.h" +#include "compiler_abstraction.h" + +#define APP_TIMER_SCHED_EVT_SIZE sizeof(app_timer_event_t) /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). */ +#define APP_TIMER_CLOCK_FREQ 32768 /**< Clock frequency of the RTC timer used to implement the app timer module. */ +#define APP_TIMER_MIN_TIMEOUT_TICKS 5 /**< Minimum value of the timeout_ticks parameter of app_timer_start(). */ + +#define APP_TIMER_NODE_SIZE 40 /**< Size of app_timer.timer_node_t (only for use inside APP_TIMER_BUF_SIZE()). */ +#define APP_TIMER_USER_OP_SIZE 24 /**< Size of app_timer.timer_user_op_t (only for use inside APP_TIMER_BUF_SIZE()). */ +#define APP_TIMER_USER_SIZE 8 /**< Size of app_timer.timer_user_t (only for use inside APP_TIMER_BUF_SIZE()). */ +#define APP_TIMER_INT_LEVELS 3 /**< Number of interrupt levels from where timer operations may be initiated (only for use inside APP_TIMER_BUF_SIZE()). */ + +/**@brief Compute number of bytes required to hold the application timer data structures. + * + * @param[in] MAX_TIMERS Maximum number of timers that can be created at any given time. + * @param[in] OP_QUEUE_SIZE Size of queues holding timer operations that are pending execution. + * NOTE: Due to the queue implementation, this size must be one more + * than the size that is actually needed. + * + * @return Required application timer buffer size (in bytes). + */ +#define APP_TIMER_BUF_SIZE(MAX_TIMERS, OP_QUEUE_SIZE) \ + ( \ + ((MAX_TIMERS) * APP_TIMER_NODE_SIZE) \ + + \ + ( \ + APP_TIMER_INT_LEVELS \ + * \ + (APP_TIMER_USER_SIZE + ((OP_QUEUE_SIZE) + 1) * APP_TIMER_USER_OP_SIZE) \ + ) \ + ) + +/**@brief Convert milliseconds to timer ticks. + * + * @note This macro uses 64 bit integer arithmetic, but as long as the macro parameters are + * constants (i.e. defines), the computation will be done by the preprocessor. + * + * @param[in] MS Milliseconds. + * @param[in] PRESCALER Value of the RTC1 PRESCALER register (must be the same value that was + * passed to APP_TIMER_INIT()). + * + * @note When using this macro, it is the responsibility of the developer to ensure that the + * values provided as input result in an output value that is supported by the + * @ref app_timer_start function. For example, when the ticks for 1 ms is needed, the + * maximum possible value of PRESCALER must be 6, when @ref APP_TIMER_CLOCK_FREQ is 32768. + * This will result in a ticks value as 5. Any higher value for PRESCALER will result in a + * ticks value that is not supported by this module. + * + * @return Number of timer ticks. + */ +#define APP_TIMER_TICKS(MS, PRESCALER)\ + ((uint32_t)ROUNDED_DIV((MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, ((PRESCALER) + 1) * 1000)) + +/**@brief Timer id type. */ +typedef uint32_t app_timer_id_t; + +/**@brief Application timeout handler type. */ +typedef void (*app_timer_timeout_handler_t)(void * p_context); + +/**@brief Type of function for passing events from the timer module to the scheduler. */ +typedef uint32_t (*app_timer_evt_schedule_func_t) (app_timer_timeout_handler_t timeout_handler, + void * p_context); + +/**@brief Timer modes. */ +typedef enum +{ + APP_TIMER_MODE_SINGLE_SHOT, /**< The timer will expire only once. */ + APP_TIMER_MODE_REPEATED /**< The timer will restart each time it expires. */ +} app_timer_mode_t; + +/**@brief Macro for initializing the application timer module. + * + * @details It will handle dimensioning and allocation of the memory buffer required by the timer, + * making sure that the buffer is correctly aligned. It will also connect the timer module + * to the scheduler (if specified). + * + * @param[in] PRESCALER Value of the RTC1 PRESCALER register. This will decide the + * timer tick rate. Set to 0 for no prescaling. + * @param[in] MAX_TIMERS Maximum number of timers that can be created at any given time. + * @param[in] OP_QUEUES_SIZE Size of queues holding timer operations that are pending execution. + * @param[in] USE_SCHEDULER TRUE if the application is using the event scheduler, + * FALSE otherwise. + * + * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it + * several times as long as it is from the same location, e.g. to do a reinitialization). + */ +/*lint -emacro(506, APP_TIMER_INIT) */ /* Suppress "Constant value Boolean */ +#define APP_TIMER_INIT(PRESCALER, MAX_TIMERS, OP_QUEUES_SIZE, USE_SCHEDULER) \ + do \ + { \ + static uint32_t APP_TIMER_BUF[CEIL_DIV(APP_TIMER_BUF_SIZE((MAX_TIMERS), \ + (OP_QUEUES_SIZE) + 1), \ + sizeof(uint32_t))]; \ + uint32_t ERR_CODE = app_timer_init((PRESCALER), \ + (MAX_TIMERS), \ + (OP_QUEUES_SIZE) + 1, \ + APP_TIMER_BUF, \ + (USE_SCHEDULER) ? app_timer_evt_schedule : NULL); \ + APP_ERROR_CHECK(ERR_CODE); \ + } while (0) + +/**@brief Function for initializing the timer module. + * + * @note Normally initialization should be done using the APP_TIMER_INIT() macro, as that will both + * allocate the buffers needed by the timer module (including aligning the buffers correctly, + * and also take care of connecting the timer module to the scheduler (if specified). + * + * @param[in] prescaler Value of the RTC1 PRESCALER register. Set to 0 for no prescaling. + * @param[in] max_timers Maximum number of timers that can be created at any given time. + * @param[in] op_queues_size Size of queues holding timer operations that are pending + * execution. NOTE: Due to the queue implementation, this size must + * be one more than the size that is actually needed. + * @param[in] p_buffer Pointer to memory buffer for internal use in the app_timer + * module. The size of the buffer can be computed using the + * APP_TIMER_BUF_SIZE() macro. The buffer must be aligned to a + * 4 byte boundary. + * @param[in] evt_schedule_func Function for passing timeout events to the scheduler. Point to + * app_timer_evt_schedule() to connect to the scheduler. Set to NULL + * to make the timer module call the timeout handler directly from + * the timer interrupt handler. + * + * @retval NRF_SUCCESS Successful initialization. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte + * boundary or NULL). + */ +uint32_t app_timer_init(uint32_t prescaler, + uint8_t max_timers, + uint8_t op_queues_size, + void * p_buffer, + app_timer_evt_schedule_func_t evt_schedule_func); + +/**@brief Function for creating a timer instance. + * + * @param[out] p_timer_id Id of the newly created timer. + * @param[in] mode Timer mode. + * @param[in] timeout_handler Function to be executed when the timer expires. + * + * @retval NRF_SUCCESS Timer was successfully created. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter. + * @retval NRF_ERROR_INVALID_STATE Application timer module has not been initialized. + * @retval NRF_ERROR_NO_MEM Maximum number of timers has already been reached. + * + * @note This function does the timer allocation in the caller's context. It is also not protected + * by a critical region. Therefore care must be taken not to call it from several interrupt + * levels simultaneously. + */ +uint32_t app_timer_create(app_timer_id_t * p_timer_id, + app_timer_mode_t mode, + app_timer_timeout_handler_t timeout_handler); + +/**@brief Function for starting a timer. + * + * @param[in] timer_id Id of timer to start. + * @param[in] timeout_ticks Number of ticks (of RTC1, including prescaling) to timeout event + * (minimum 5 ticks). + * @param[in] p_context General purpose pointer. Will be passed to the timeout handler when + * the timer expires. + * + * @retval NRF_SUCCESS Timer was successfully started. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter. + * @retval NRF_ERROR_INVALID_STATE Application timer module has not been initialized, or timer + * has not been created. + * @retval NRF_ERROR_NO_MEM Timer operations queue was full. + * + * @note The minimum timeout_ticks value is 5. + * @note For multiple active timers, timeouts occurring in close proximity to each other (in the + * range of 1 to 3 ticks) will have a positive jitter of maximum 3 ticks. + * @note When calling this method on a timer which is already running, the second start operation + * will be ignored. + */ +uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context); + +/**@brief Function for stopping the specified timer. + * + * @param[in] timer_id Id of timer to stop. + * + * @retval NRF_SUCCESS Timer was successfully stopped. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter. + * @retval NRF_ERROR_INVALID_STATE Application timer module has not been initialized, or timer + * has not been created. + * @retval NRF_ERROR_NO_MEM Timer operations queue was full. + */ +uint32_t app_timer_stop(app_timer_id_t timer_id); + +/**@brief Function for stopping all running timers. + * + * @retval NRF_SUCCESS All timers were successfully stopped. + * @retval NRF_ERROR_INVALID_STATE Application timer module has not been initialized. + * @retval NRF_ERROR_NO_MEM Timer operations queue was full. + */ +uint32_t app_timer_stop_all(void); + +/**@brief Function for returning the current value of the RTC1 counter. + * + * @param[out] p_ticks Current value of the RTC1 counter. + * + * @retval NRF_SUCCESS Counter was successfully read. + */ +uint32_t app_timer_cnt_get(uint32_t * p_ticks); + +/**@brief Function for computing the difference between two RTC1 counter values. + * + * @param[in] ticks_to Value returned by app_timer_cnt_get(). + * @param[in] ticks_from Value returned by app_timer_cnt_get(). + * @param[out] p_ticks_diff Number of ticks from ticks_from to ticks_to. + * + * @retval NRF_SUCCESS Counter difference was successfully computed. + */ +uint32_t app_timer_cnt_diff_compute(uint32_t ticks_to, + uint32_t ticks_from, + uint32_t * p_ticks_diff); + + +// Type and functions for connecting the timer to the scheduler: + +/**@cond NO_DOXYGEN */ +typedef struct +{ + app_timer_timeout_handler_t timeout_handler; + void * p_context; +} app_timer_event_t; + +static __INLINE void app_timer_evt_get(void * p_event_data, uint16_t event_size) +{ + app_timer_event_t * p_timer_event = (app_timer_event_t *)p_event_data; + + APP_ERROR_CHECK_BOOL(event_size == sizeof(app_timer_event_t)); + p_timer_event->timeout_handler(p_timer_event->p_context); +} + +static __INLINE uint32_t app_timer_evt_schedule(app_timer_timeout_handler_t timeout_handler, + void * p_context) +{ + app_timer_event_t timer_event; + + timer_event.timeout_handler = timeout_handler; + timer_event.p_context = p_context; + + return app_sched_event_put(&timer_event, sizeof(timer_event), app_timer_evt_get); +} +/**@endcond */ + +#endif // APP_TIMER_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_uart.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_uart.h new file mode 100644 index 0000000000..7dfba85300 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_uart.h @@ -0,0 +1,285 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/**@file + * + * @defgroup app_uart UART module + * @{ + * @ingroup app_common + * + * @brief UART module interface. + */ + +#ifndef APP_UART_H__ +#define APP_UART_H__ + +#include +#include +#include "nordic_global.h" +#include "app_util.h" + +#define UART_PIN_DISCONNECTED 0xFFFFFFFF /**< Value indicating that no pin is connected to this UART register. */ + +/**@brief UART Flow Control modes for the peripheral. + */ +typedef enum +{ + APP_UART_FLOW_CONTROL_DISABLED, /**< UART Hw Flow Control is disabled. */ + APP_UART_FLOW_CONTROL_ENABLED, /**< Standard UART Hw Flow Control is enabled. */ + APP_UART_FLOW_CONTROL_LOW_POWER /**< Specialized UART Hw Flow Control is used. The Low Power setting allows the nRF51 to Power Off the UART module when CTS is in-active, and re-enabling the UART when the CTS signal becomes active. This allows the nRF51 to safe power by only using the UART module when it is needed by the remote site. */ +} app_uart_flow_control_t; + +/**@brief UART communication structure holding configuration settings for the peripheral. + */ +typedef struct +{ + uint8_t rx_pin_no; /**< RX pin number. */ + uint8_t tx_pin_no; /**< TX pin number. */ + uint8_t rts_pin_no; /**< RTS pin number, only used if flow control is enabled. */ + uint8_t cts_pin_no; /**< CTS pin number, only used if flow control is enabled. */ + app_uart_flow_control_t flow_control; /**< Flow control setting, if flow control is used, the system will use low power UART mode, based on CTS signal. */ + bool use_parity; /**< Even parity if TRUE, no parity if FALSE. */ + uint32_t baud_rate; /**< Baud rate configuration. */ +} app_uart_comm_params_t; + +/**@brief UART buffer for transmitting/receiving data. + */ +typedef struct +{ + uint8_t * rx_buf; /**< Pointer to the RX buffer. */ + uint32_t rx_buf_size; /**< Size of the RX buffer. */ + uint8_t * tx_buf; /**< Pointer to the TX buffer. */ + uint32_t tx_buf_size; /**< Size of the TX buffer. */ +} app_uart_buffers_t; + +/**@brief Enumeration describing current state of the UART. + * + * @details The connection state can be fetched by the application using the function call + * @ref app_uart_get_connection_state. + * When hardware flow control is used + * - APP_UART_CONNECTED: Communication is ongoing. + * - APP_UART_DISCONNECTED: No communication is ongoing. + * + * When no hardware flow control is used + * - APP_UART_CONNECTED: Always returned as bytes can always be received/transmitted. + */ +typedef enum +{ + APP_UART_DISCONNECTED, /**< State indicating that the UART is disconnected and cannot receive or transmit bytes. */ + APP_UART_CONNECTED /**< State indicating that the UART is connected and ready to receive or transmit bytes. If flow control is disabled, the state will always be connected. */ +} app_uart_connection_state_t; + +/**@brief Enumeration which defines events used by the UART module upon data reception or error. + * + * @details The event type is used to indicate the type of additional information in the event + * @ref app_uart_evt_t. + */ +typedef enum +{ + APP_UART_DATA_READY, /**< An event indicating that UART data has been received. The data is available in the FIFO and can be fetched using @ref app_uart_get. */ + APP_UART_FIFO_ERROR, /**< An error in the FIFO module used by the app_uart module has occured. The FIFO error code is stored in app_uart_evt_t.data.error_code field. */ + APP_UART_COMMUNICATION_ERROR, /**< An communication error has occured during reception. The error is stored in app_uart_evt_t.data.error_communication field. */ + APP_UART_TX_EMPTY, /**< An event indicating that UART has completed transmission of all available data in the TX FIFO. */ + APP_UART_DATA, /**< An event indicating that UART data has been received, and data is present in data field. This event is only used when no FIFO is configured. */ +} app_uart_evt_type_t; + +/**@brief Struct containing events from the UART module. + * + * @details The app_uart_evt_t is used to notify the application of asynchronous events when data + * are received on the UART peripheral or in case an error occured during data reception. + */ +typedef struct +{ + app_uart_evt_type_t evt_type; /**< Type of event. */ + union + { + uint32_t error_communication;/**< Field used if evt_type is: APP_UART_COMMUNICATION_ERROR. This field contains the value in the ERRORSRC register for the UART peripheral. The UART_ERRORSRC_x defines from @ref nrf51_bitfields.h can be used to parse the error code. See also the nRF51 Series Reference Manual for specification. */ + uint32_t error_code; /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */ + uint8_t value; /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */ + } data; +} app_uart_evt_t; + +/**@brief Function for handling app_uart event callback. + * + * @details Upon an event in the app_uart module this callback function will be called to notify + * the applicatioon about the event. + * + * @param[in] p_app_uart_event Pointer to UART event. + */ +typedef void (*app_uart_event_handler_t) (app_uart_evt_t * p_app_uart_event); + +/**@brief Macro for safe initialization of the UART module in a single user instance when using + * a FIFO together with UART. + * + * @param[in] P_COMM_PARAMS Pointer to a UART communication structure: app_uart_comm_params_t + * @param[in] RX_BUF_SIZE Size of desired RX buffer, must be a power of 2 or ZERO (No FIFO). + * @param[in] TX_BUF_SIZE Size of desired TX buffer, must be a power of 2 or ZERO (No FIFO). + * @param[in] EVENT_HANDLER Event handler function to be called when an event occurs in the + * UART module. + * @param[in] IRQ_PRIO IRQ priority, app_irq_priority_t, for the UART module irq handler. + * @param[out] ERR_CODE The return value of the UART initialization function will be + * written to this parameter. + * + * @note Since this macro allocates a buffer and registers the module as a GPIOTE user when flow + * control is enabled, it must only be called once. + */ +#define APP_UART_FIFO_INIT(P_COMM_PARAMS, RX_BUF_SIZE, TX_BUF_SIZE, EVT_HANDLER, IRQ_PRIO, ERR_CODE)\ + do \ + { \ + uint16_t APP_UART_UID = 0; \ + app_uart_buffers_t buffers; \ + static uint8_t rx_buf[RX_BUF_SIZE]; \ + static uint8_t tx_buf[TX_BUF_SIZE]; \ + \ + buffers.rx_buf = rx_buf; \ + buffers.rx_buf_size = sizeof(rx_buf); \ + buffers.tx_buf = tx_buf; \ + buffers.tx_buf_size = sizeof(tx_buf); \ + ERR_CODE = app_uart_init(P_COMM_PARAMS, &buffers, EVT_HANDLER, IRQ_PRIO, &APP_UART_UID); \ + } while (0) + +/**@brief Macro for safe initialization of the UART module in a single user instance. + * + * @param[in] P_COMM_PARAMS Pointer to a UART communication structure: app_uart_comm_params_t + * @param[in] EVENT_HANDLER Event handler function to be called when an event occurs in the + * UART module. + * @param[in] IRQ_PRIO IRQ priority, app_irq_priority_t, for the UART module irq handler. + * @param[out] ERR_CODE The return value of the UART initialization function will be + * written to this parameter. + * + * @note Since this macro allocates registers the module as a GPIOTE user when flow control is + * enabled, it must only be called once. + */ +#define APP_UART_INIT(P_COMM_PARAMS, EVT_HANDLER, IRQ_PRIO, ERR_CODE) \ + do \ + { \ + uint16_t APP_UART_UID = 0; \ + ERR_CODE = app_uart_init(P_COMM_PARAMS, NULL, EVT_HANDLER, IRQ_PRIO, &APP_UART_UID); \ + } while (0) + +/**@brief Function for initializing the UART module. Use this initialization when several instances of the UART + * module are needed. + * + * @details This initialization will return a UART user id for the caller. The UART user id must be + * used upon re-initialization of the UART or closing of the module for the user. + * If single instance usage is needed, the APP_UART_INIT() macro should be used instead. + * + * @note Normally single instance initialization should be done using the APP_UART_INIT() or + * APP_UART_INIT_FIFO() macro depending on whether the FIFO should be used by the UART, as + * that will allocate the buffers needed by the UART module (including aligning the buffer + * correctly). + + * @param[in] p_comm_params Pin and communication parameters. + * @param[in] p_buffers RX and TX buffers, NULL is FIFO is not used. + * @param[in] error_handler Function to be called in case of an error. + * @param[in] app_irq_priority Interrupt priority level. + * @param[in,out] p_uart_uid User id for the UART module. The p_uart_uid must be used if + * re-initialization and/or closing of the UART module is needed. + * If the value pointed to by p_uart_uid is zero, this is + * considdered a first time initialization. Otherwise this is + * considered a re-initialization for the user with id *p_uart_uid. + * + * @retval NRF_SUCCESS If successful initialization. + * @retval NRF_ERROR_INVALID_LENGTH If a provided buffer is not a power of two. + * @retval NRF_ERROR_NULL If one of the provided buffers is a NULL pointer. + * + * Those errors are propagated by the UART module to the caller upon registration when Hardware Flow + * Control is enabled. When Hardware Flow Control is not used, those errors cannot occur. + * @retval NRF_ERROR_INVALID_STATE The GPIOTE module is not in a valid state when registering + * the UART module as a user. + * @retval NRF_ERROR_INVALID_PARAM The UART module provides an invalid callback function when + * registering the UART module as a user. + * Or the value pointed to by *p_uart_uid is not a valid + * GPIOTE number. + * @retval NRF_ERROR_NO_MEM GPIOTE module has reached the maximum number of users. + */ +uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params, + app_uart_buffers_t * p_buffers, + app_uart_event_handler_t error_handler, + app_irq_priority_t irq_priority, + uint16_t * p_uart_uid); + +/**@brief Function for getting a byte from the UART. + * + * @details This function will get the next byte from the RX buffer. If the RX buffer is empty + * an error code will be returned and the app_uart module will generate an event upon + * reception of the first byte which is added to the RX buffer. + * + * @param[out] p_byte Pointer to an address where next byte received on the UART will be copied. + * + * @retval NRF_SUCCESS If a byte has been received and pushed to the pointer provided. + * @retval NRF_ERROR_NOT_FOUND If no byte is available in the RX buffer of the app_uart module. + */ +uint32_t app_uart_get(uint8_t * p_byte); + +/**@brief Function for putting a byte on the UART. + * + * @details This call is non-blocking. + * + * @param[in] byte Byte to be transmitted on the UART. + * + * @retval NRF_SUCCESS If the byte was succesfully put on the TX buffer for transmission. + * @retval NRF_ERROR_NO_MEM If no more space is available in the TX buffer. + * NRF_ERROR_NO_MEM may occur if flow control is enabled and CTS signal + * is high for a long period and the buffer fills up. + */ +uint32_t app_uart_put(uint8_t byte); + +/**@brief Function for getting the current state of the UART. + * + * @details If flow control is disabled, the state is assumed to always be APP_UART_CONNECTED. + * + * When using flow control the state will be controlled by the CTS. If CTS is set active + * by the remote side, or the app_uart module is in the process of transmitting a byte, + * app_uart is in APP_UART_CONNECTED state. If CTS is set inactive by remote side app_uart + * will not get into APP_UART_DISCONNECTED state until the last byte in the TXD register + * is fully transmitted. + * + * Internal states in the state machine are mapped to the general connected/disconnected + * states in the following ways: + * + * - UART_ON = CONNECTED + * - UART_READY = CONNECTED + * - UART_WAIT = CONNECTED + * - UART_OFF = DISCONNECTED. + * + * @param[out] p_connection_state Current connection state of the UART. + * + * @retval NRF_SUCCESS The connection state was succesfully retrieved. + */ +uint32_t app_uart_get_connection_state(app_uart_connection_state_t * p_connection_state); + +/**@brief Function for flushing the RX and TX buffers (Only valid if FIFO is used). + * This function does nothing if FIFO is not used. + * + * @retval NRF_SUCCESS Flushing completed (Current implementation will always succeed). + */ +uint32_t app_uart_flush(void); + +/**@brief Function for closing the UART module. + * + * @details This function will close any on-going UART transmissions and disable itself in the + * GPTIO module. + * + * @param[in] app_uart_uid User id for the UART module. The app_uart_uid must be identical to the + * UART id returned on initialization and which is currently in use. + + * @retval NRF_SUCCESS If successfully closed. + * @retval NRF_ERROR_INVALID_PARAM If an invalid user id is provided or the user id differs from + * the current active user. + */ +uint32_t app_uart_close(uint16_t app_uart_id); + + +#endif // APP_UART_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_util.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_util.h new file mode 100644 index 0000000000..241cf25e01 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/app_util.h @@ -0,0 +1,308 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup app_util Utility Functions and Definitions + * @{ + * @ingroup app_common + * + * @brief Various types and definitions available to all applications. + */ + +#ifndef APP_UTIL_H__ +#define APP_UTIL_H__ + +#include +#include "nordic_global.h" +#include "compiler_abstraction.h" +#include "nrf51.h" +#include "app_error.h" + +/**@brief The interrupt priorities available to the application while the softdevice is active. */ +typedef enum +{ + APP_IRQ_PRIORITY_HIGH = 1, + APP_IRQ_PRIORITY_LOW = 3 +} app_irq_priority_t; + +enum +{ + UNIT_0_625_MS = 625, /**< Number of microseconds in 0.625 milliseconds. */ + UNIT_1_25_MS = 1250, /**< Number of microseconds in 1.25 milliseconds. */ + UNIT_10_MS = 10000 /**< Number of microseconds in 10 milliseconds. */ +}; + +#define NRF_APP_PRIORITY_THREAD 4 /**< "Interrupt level" when running in Thread Mode. */ + +/**@cond NO_DOXYGEN */ +#define EXTERNAL_INT_VECTOR_OFFSET 16 +/**@endcond */ + +#define PACKED(TYPE) __packed TYPE + +/**@brief Macro for doing static (i.e. compile time) assertion. + * + * @note If the assertion fails when compiling using Keil, the compiler will report error message + * "error: #94: the size of an array must be greater than zero" (while gcc will list the + * symbol static_assert_failed, making the error message more readable). + * If the supplied expression can not be evaluated at compile time, Keil will report + * "error: #28: expression must have a constant value". + * + * @note The macro is intentionally implemented not using do while(0), allowing it to be used + * outside function blocks (e.g. close to global type- and variable declarations). + * If used in a code block, it must be used before any executable code in this block. + * + * @param[in] EXPR Constant expression to be verified. + */ + +#define STATIC_ASSERT(EXPR) typedef char static_assert_failed[(EXPR) ? 1 : -1] + +/**@brief type for holding an encoded (i.e. little endian) 16 bit unsigned integer. */ +typedef uint8_t uint16_le_t[2]; + +/**@brief type for holding an encoded (i.e. little endian) 32 bit unsigned integer. */ +typedef uint8_t uint32_le_t[4]; + +/**@brief Byte array type. */ +typedef struct +{ + uint16_t size; /**< Number of array entries. */ + uint8_t * p_data; /**< Pointer to array entries. */ +} uint8_array_t; + +/**@brief Macro for entering a critical region. + * + * @note Due to implementation details, there must exist one and only one call to + * CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located + * in the same scope. + */ +#define CRITICAL_REGION_ENTER() \ + { \ + uint8_t IS_NESTED_CRITICAL_REGION = 0; \ + uint32_t CURRENT_INT_PRI = current_int_priority_get(); \ + if (CURRENT_INT_PRI != APP_IRQ_PRIORITY_HIGH) \ + { \ + uint32_t ERR_CODE = sd_nvic_critical_region_enter(&IS_NESTED_CRITICAL_REGION); \ + if (ERR_CODE == NRF_ERROR_SOFTDEVICE_NOT_ENABLED) \ + { \ + __disable_irq(); \ + } \ + else \ + { \ + APP_ERROR_CHECK(ERR_CODE); \ + } \ + } + +/**@brief Macro for leaving a critical region. + * + * @note Due to implementation details, there must exist one and only one call to + * CRITICAL_REGION_EXIT() for each call to CRITICAL_REGION_ENTER(), and they must be located + * in the same scope. + */ +#define CRITICAL_REGION_EXIT() \ + if (CURRENT_INT_PRI != APP_IRQ_PRIORITY_HIGH) \ + { \ + uint32_t ERR_CODE; \ + __enable_irq(); \ + ERR_CODE = sd_nvic_critical_region_exit(IS_NESTED_CRITICAL_REGION); \ + if (ERR_CODE != NRF_ERROR_SOFTDEVICE_NOT_ENABLED) \ + { \ + APP_ERROR_CHECK(ERR_CODE); \ + } \ + } \ + } + +/**@brief Perform rounded integer division (as opposed to truncating the result). + * + * @param[in] A Numerator. + * @param[in] B Denominator. + * + * @return Rounded (integer) result of dividing A by B. + */ +#define ROUNDED_DIV(A, B) (((A) + ((B) / 2)) / (B)) + +/**@brief Check if the integer provided is a power of two. + * + * @param[in] A Number to be tested. + * + * @return true if value is power of two. + * @return false if value not power of two. + */ +#define IS_POWER_OF_TWO(A) ( ((A) != 0) && ((((A) - 1) & (A)) == 0) ) + +/**@brief To convert ticks to millisecond + * @param[in] time Number of millseconds that needs to be converted. + * @param[in] resolution Units to be converted. + */ +#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION)) + + +/**@brief Perform integer division, making sure the result is rounded up. + * + * @details One typical use for this is to compute the number of objects with size B is needed to + * hold A number of bytes. + * + * @param[in] A Numerator. + * @param[in] B Denominator. + * + * @return Integer result of dividing A by B, rounded up. + */ +#define CEIL_DIV(A, B) \ + /*lint -save -e573 */ \ + ((((A) - 1) / (B)) + 1) \ + /*lint -restore */ + +/**@brief Function for encoding a uint16 value. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data is to be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint16_encode(uint16_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) ((value & 0x00FF) >> 0); + p_encoded_data[1] = (uint8_t) ((value & 0xFF00) >> 8); + return sizeof(uint16_t); +} + +/**@brief Function for encoding a uint32 value. + * + * @param[in] value Value to be encoded. + * @param[out] p_encoded_data Buffer where the encoded data is to be written. + * + * @return Number of bytes written. + */ +static __INLINE uint8_t uint32_encode(uint32_t value, uint8_t * p_encoded_data) +{ + p_encoded_data[0] = (uint8_t) ((value & 0x000000FF) >> 0); + p_encoded_data[1] = (uint8_t) ((value & 0x0000FF00) >> 8); + p_encoded_data[2] = (uint8_t) ((value & 0x00FF0000) >> 16); + p_encoded_data[3] = (uint8_t) ((value & 0xFF000000) >> 24); + return sizeof(uint32_t); +} + +/**@brief Function for decoding a uint16 value. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. + */ +static __INLINE uint16_t uint16_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint16_t)((uint8_t *)p_encoded_data)[0])) | + (((uint16_t)((uint8_t *)p_encoded_data)[1]) << 8 )); +} + +/**@brief Function for decoding a uint32 value. + * + * @param[in] p_encoded_data Buffer where the encoded data is stored. + * + * @return Decoded value. + */ +static __INLINE uint32_t uint32_decode(const uint8_t * p_encoded_data) +{ + return ( (((uint32_t)((uint8_t *)p_encoded_data)[0]) << 0) | + (((uint32_t)((uint8_t *)p_encoded_data)[1]) << 8) | + (((uint32_t)((uint8_t *)p_encoded_data)[2]) << 16) | + (((uint32_t)((uint8_t *)p_encoded_data)[3]) << 24 )); +} + + +/**@brief Function for finding the current interrupt level. + * + * @return Current interrupt level. + * @retval APP_IRQ_PRIORITY_HIGH We are running in Application High interrupt level. + * @retval APP_IRQ_PRIORITY_LOW We are running in Application Low interrupt level. + * @retval APP_IRQ_PRIORITY_THREAD We are running in Thread Mode. + */ +static __INLINE uint8_t current_int_priority_get(void) +{ + uint32_t isr_vector_num = (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk); + if (isr_vector_num > 0) + { + int32_t irq_type = ((int32_t)isr_vector_num - EXTERNAL_INT_VECTOR_OFFSET); + return (NVIC_GetPriority((IRQn_Type)irq_type) & 0xFF); + } + else + { + return NRF_APP_PRIORITY_THREAD; + } +} + +/** @brief Function for converting the input voltage (in milli volts) into percentage of 3.0 Volts. + * + * @details The calculation is based on a linearized version of the battery's discharge + * curve. 3.0V returns 100% battery level. The limit for power failure is 2.1V and + * is considered to be the lower boundary. + * + * The discharge curve for CR2032 is non-linear. In this model it is split into + * 4 linear sections: + * - Section 1: 3.0V - 2.9V = 100% - 42% (58% drop on 100 mV) + * - Section 2: 2.9V - 2.74V = 42% - 18% (24% drop on 160 mV) + * - Section 3: 2.74V - 2.44V = 18% - 6% (12% drop on 300 mV) + * - Section 4: 2.44V - 2.1V = 6% - 0% (6% drop on 340 mV) + * + * These numbers are by no means accurate. Temperature and + * load in the actual application is not accounted for! + * + * @param[in] mvolts The voltage in mV + * + * @return Battery level in percent. +*/ +static __INLINE uint8_t battery_level_in_percent(const uint16_t mvolts) +{ + uint8_t battery_level; + + if (mvolts >= 3000) + { + battery_level = 100; + } + else if (mvolts > 2900) + { + battery_level = 100 - ((3000 - mvolts) * 58) / 100; + } + else if (mvolts > 2740) + { + battery_level = 42 - ((2900 - mvolts) * 24) / 160; + } + else if (mvolts > 2440) + { + battery_level = 18 - ((2740 - mvolts) * 12) / 300; + } + else if (mvolts > 2100) + { + battery_level = 6 - ((2440 - mvolts) * 6) / 340; + } + else + { + battery_level = 0; + } + + return battery_level; +} + +/**@brief Function for checking if a pointer value is aligned to a 4 byte boundary. + * + * @param[in] p Pointer value to be checked. + * + * @return TRUE if pointer is aligned to a 4 byte boundary, FALSE otherwise. + */ +static __INLINE bool is_word_aligned(void * p) +{ + return (((uint32_t)p & 0x00000003) == 0); +} + +#endif // APP_UTIL_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/crc16.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/crc16.h new file mode 100644 index 0000000000..8aa779e4ab --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/crc16.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup crc_compute CRC compute + * @{ + * @ingroup hci_transport + * + * @brief This module implements the CRC-16 calculation in the blocks. + */ + +#ifndef CRC16_H__ +#define CRC16_H__ + +#include +#include "nordic_global.h" + +/**@brief Function for calculating CRC-16 in blocks. + * + * Feed each consecutive data block into this function, along with the current value of p_crc as + * returned by the previous call of this function. The first call of this function should pass NULL + * as the initial value of the crc in p_crc. + * + * @param[in] p_data The input data block for computation. + * @param[in] size The size of the input data block in bytes. + * @param[in] p_crc The previous calculated CRC-16 value or NULL if first call. + * + * @return The updated CRC-16 value, based on the input supplied. + */ +uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc); + +#endif // CRC16_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool.h new file mode 100644 index 0000000000..6c5016fd72 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool.h @@ -0,0 +1,133 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup memory_pool Memory pool + * @{ + * @ingroup app_common + * + * @brief Memory pool implementation + * + * Memory pool implementation, based on circular buffer data structure, which supports asynchronous + * processing of RX data. The current default implementation supports 1 TX buffer and 4 RX buffers. + * The memory managed by the pool is allocated from static storage instead of heap. The internal + * design of the circular buffer implementing the RX memory layout is illustrated in the picture + * below. + * + * @image html memory_pool.png "Circular buffer design" + * + * The expected call order for the RX APIs is as follows: + * - hci_mem_pool_rx_produce + * - hci_mem_pool_rx_data_size_set + * - hci_mem_pool_rx_extract + * - hci_mem_pool_rx_consume + * + * @warning If the above mentioned expected call order is violated the end result can be undefined. + * + * \par Component specific configuration options + * + * The following compile time configuration options are available to suit various implementations: + * - TX_BUF_SIZE TX buffer size in bytes. + * - RX_BUF_SIZE RX buffer size in bytes. + * - RX_BUF_QUEUE_SIZE RX buffer element size. + */ + +#ifndef HCI_MEM_POOL_H__ +#define HCI_MEM_POOL_H__ + +#include +#include "nordic_global.h" +#include "nrf_error.h" + +/**@brief Function for opening the module. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t hci_mem_pool_open(void); + +/**@brief Function for closing the module. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t hci_mem_pool_close(void); + +/**@brief Function for allocating requested amount of TX memory. + * + * @param[out] pp_buffer Pointer to the allocated memory. + * + * @retval NRF_SUCCESS Operation success. Memory was allocated. + * @retval NRF_ERROR_NO_MEM Operation failure. No memory available for allocation. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + */ +uint32_t hci_mem_pool_tx_alloc(void ** pp_buffer); + +/**@brief Function for freeing previously allocated TX memory. + * + * @note Memory management follows the FIFO principle meaning that free() order must match the + * alloc(...) order, which is the reason for omitting exact memory block identifier as an + * input parameter. + * + * @retval NRF_SUCCESS Operation success. Memory was freed. + */ +uint32_t hci_mem_pool_tx_free(void); + +/**@brief Function for producing a free RX memory block for usage. + * + * @note Upon produce request amount being 0, NRF_SUCCESS is returned. + * + * @param[in] length Amount, in bytes, of free memory to be produced. + * @param[out] pp_buffer Pointer to the allocated memory. + * + * @retval NRF_SUCCESS Operation success. Free RX memory block produced. + * @retval NRF_ERROR_NO_MEM Operation failure. No suitable memory available for allocation. + * @retval NRF_ERROR_DATA_SIZE Operation failure. Request size exceeds limit. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + */ +uint32_t hci_mem_pool_rx_produce(uint32_t length, void ** pp_buffer); + +/**@brief Function for setting the length of the last produced RX memory block. + * + * @warning If call to this API is omitted the end result is that the following call to + * mem_pool_rx_extract will return incorrect data in the p_length output parameter. + * + * @param[in] length Amount, in bytes, of actual memory used. + * + * @retval NRF_SUCCESS Operation success. Length was set. + */ +uint32_t hci_mem_pool_rx_data_size_set(uint32_t length); + +/**@brief Function for extracting a packet, which has been filled with read data, for further + * processing. + * + * @param[out] pp_buffer Pointer to the packet data. + * @param[out] p_length Length of packet data in bytes. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to extract. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + */ +uint32_t hci_mem_pool_rx_extract(uint8_t ** pp_buffer, uint32_t * p_length); + +/**@brief Function for freeing previously extracted packet, which has been filled with read data. + * + * @param[in] p_buffer Pointer to consumed buffer. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to free. + * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer. + */ +uint32_t hci_mem_pool_rx_consume(uint8_t * p_buffer); + +#endif // HCI_MEM_POOL_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool_internal.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool_internal.h new file mode 100644 index 0000000000..f1fa77fea6 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool_internal.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup memory_pool_internal Memory Pool Internal + * @{ + * @ingroup memory_pool + * + * @brief Memory pool internal definitions + */ + +#ifndef MEM_POOL_INTERNAL_H__ +#define MEM_POOL_INTERNAL_H__ + +#define TX_BUF_SIZE 600u /**< TX buffer size in bytes. */ +#define RX_BUF_SIZE TX_BUF_SIZE /**< RX buffer size in bytes. */ + +#define RX_BUF_QUEUE_SIZE 4u /**< RX buffer element size. */ + +#endif // MEM_POOL_INTERNAL_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_slip.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_slip.h new file mode 100644 index 0000000000..d6205f6cfd --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_slip.h @@ -0,0 +1,130 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup hci_slip SLIP module + * @{ + * @ingroup app_common + * + * @brief SLIP layer for supporting packet framing in HCI transport. + * + * @details This module implements SLIP packet framing as described in the Bluetooth Core + * Specification 4.0, Volume 4, Part D, Chapter 3 SLIP Layer. + * + * SLIP framing ensures that all packets sent on the UART are framed as: + * <0xC0> SLIP packet 1 <0xC0> <0xC0> SLIP packet 2 <0xC0>. + * + * The SLIP layer uses events to notify the upper layer when data transmission is complete + * and when a SLIP packet is received. + */ + +#ifndef HCI_SLIP_H__ +#define HCI_SLIP_H__ + +#include +#include "nordic_global.h" + +/**@brief Event types from the SLIP Layer. */ +typedef enum +{ + HCI_SLIP_RX_RDY, /**< An event indicating that an RX packet is ready to be read. */ + HCI_SLIP_TX_DONE, /**< An event indicating write completion of the TX packet provided in the function call \ref hci_slip_write . */ + HCI_SLIP_RX_OVERFLOW, /**< An event indicating that RX data has been discarded due to lack of free RX memory. */ + HCI_SLIP_ERROR, /**< An event indicating that an unrecoverable error has occurred. */ + HCI_SLIP_EVT_TYPE_MAX /**< Enumeration upper bound. */ +} hci_slip_evt_type_t; + +/**@brief Structure containing an event from the SLIP layer. + */ +typedef struct +{ + hci_slip_evt_type_t evt_type; /**< Type of event. */ + const uint8_t * packet; /**< This field contains a pointer to the packet for which the event relates, i.e. SLIP_TX_DONE: the packet transmitted, SLIP_RX_RDY: the packet received, SLIP_RX_OVERFLOW: The packet which overflow/or NULL if no receive buffer is available. */ + uint32_t packet_length; /**< Packet length, i.e. SLIP_TX_DONE: Bytes transmitted, SLIP_RX_RDY: Bytes received, SLIP_RX_OVERFLOW: index at which the packet overflowed. */ +} hci_slip_evt_t; + +/**@brief Function for the SLIP layer event callback. + */ +typedef void (*hci_slip_event_handler_t)(hci_slip_evt_t event); + +/**@brief Function for registering the event handler provided as parameter and this event handler + * will be used by SLIP layer to send events described in \ref hci_slip_evt_type_t. + * + * @note Multiple registration requests will overwrite any existing registration. + * + * @param[in] event_handler This function is called by the SLIP layer upon an event. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t hci_slip_evt_handler_register(hci_slip_event_handler_t event_handler); + +/**@brief Function for opening the SLIP layer. This function must be called before + * \ref hci_slip_write and before any data can be received. + * + * @note Can be called multiple times. + * + * @retval NRF_SUCCESS Operation success. + * + * The SLIP layer module will propagate errors from underlying sub-modules. + * This implementation is using UART module as a physical transmission layer, and hci_slip_open + * executes \ref app_uart_init . For an extended error list, please refer to \ref app_uart_init . + */ +uint32_t hci_slip_open(void); + +/**@brief Function for closing the SLIP layer. After this function is called no data can be + * transmitted or received in this layer. + * + * @note This function can be called multiple times and also for an unopened channel. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t hci_slip_close(void); + +/**@brief Function for writing a packet with SLIP encoding. Packet transmission is confirmed when + * the HCI_SLIP_TX_DONE event is received by the function caller. + * + * @param[in] p_buffer Pointer to the packet to transmit. + * @param[in] length Packet length, in bytes. + * + * @retval NRF_SUCCESS Operation success. Packet was encoded and added to the + * transmission queue and an event will be sent upon transmission + * completion. + * @retval NRF_ERROR_NO_MEM Operation failure. Transmission queue is full and packet was not + * added to the transmission queue. Application shall wait for + * the \ref HCI_SLIP_TX_DONE event. After HCI_SLIP_TX_DONE this + * function can be executed for transmission of next packet. + * @retval NRF_ERROR_INVALID_ADDR If a NULL pointer is provided. + * @retval NRF_ERROR_INVALID_STATE Operation failure. Module is not open. + */ +uint32_t hci_slip_write(const uint8_t * p_buffer, uint32_t length); + +/**@brief Function for registering a receive buffer. The receive buffer will be used for storage of + * received and SLIP decoded data. + * No data can be received by the SLIP layer until a receive buffer has been registered. + * + * @note The lifetime of the buffer must be valid during complete reception of data. A static + * buffer is recommended. + * + * @warning Multiple registration requests will overwrite any existing registration. + * + * @param[in] p_buffer Pointer to receive buffer. The received and SLIP decoded packet + * will be placed in this buffer. + * @param[in] length Buffer length, in bytes. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t hci_slip_rx_buffer_register(uint8_t * p_buffer, uint32_t length); + +#endif // HCI_SLIP_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_transport.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_transport.h new file mode 100644 index 0000000000..d29fbe46c9 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_transport.h @@ -0,0 +1,221 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/**@file + * + * @defgroup hci_transport HCI Transport + * @{ + * @ingroup app_common + * + * @brief HCI transport module implementation. + * + * This module implements certain specific features from the three-wire UART transport layer, + * defined by the Bluetooth specification version 4.0 [Vol 4] part D. + * + * \par Features supported + * - Transmission and reception of Vendor Specific HCI packet type application packets. + * - Transmission and reception of reliable packets: defined by chapter 6 of the specification. + * + * \par Features not supported + * - Link establishment procedure: defined by chapter 8 of the specification. + * - Low power: defined by chapter 9 of the specification. + * + * \par Implementation specific behaviour + * - As Link establishment procedure is not supported following static link configuration parameters + * are used: + * + TX window size is 1. + * + 16 bit CCITT-CRC must be used. + * + Out of frame software flow control not supported. + * + Parameters specific for resending reliable packets are compile time configurable (clarifed + * later in this document). + * + Acknowledgement packet transmissions are not timeout driven , meaning they are delivered for + * transmission within same context which the corresponding application packet was received. + * + * \par Implementation specific limitations + * Current implementation has the following limitations which will have impact to system wide + * behaviour: + * - Delayed acknowledgement scheduling not implemented: + * There exists a possibility that acknowledgement TX packet and application TX packet will collide + * in the TX pipeline having the end result that acknowledgement packet will be excluded from the TX + * pipeline which will trigger the retransmission algorithm within the peer protocol entity. + * - Delayed retransmission scheduling not implemented: + * There exists a possibility that retransmitted application TX packet and acknowledgement TX packet + * will collide in the TX pipeline having the end result that retransmitted application TX packet + * will be excluded from the TX pipeline. + * - Processing of the acknowledgement number from RX application packets: + * Acknowledgement number is not processed from the RX application packets having the end result + * that unnecessary application packet retransmissions can occur. + * + * The application TX packet processing flow is illustrated by the statemachine below. + * + * @image html hci_transport_tx_sm.png "TX - application packet statemachine" + * + * \par Component specific configuration options + * + * The following compile time configuration options are available, and used to configure the + * application TX packet retransmission interval, in order to suite various application specific + * implementations: + * - MAC_PACKET_SIZE_IN_BITS Maximum size of a single application packet in bits. + * - USED_BAUD_RATE Used uart baudrate. + * + * The following compile time configuration option is available to configure module specific + * behaviour: + * - MAX_RETRY_COUNT Max retransmission retry count for applicaton packets. + */ + +#ifndef HCI_TRANSPORT_H__ +#define HCI_TRANSPORT_H__ + +#include +#include "nordic_global.h" +#include "nrf_error.h" + +/**@brief Generic event callback function events. */ +typedef enum +{ + HCI_TRANSPORT_RX_RDY, /**< An event indicating that RX packet is ready for read. */ + HCI_TRANSPORT_EVT_TYPE_MAX /**< Enumeration upper bound. */ +} hci_transport_evt_type_t; + +/**@brief Struct containing events from the Transport layer. + */ +typedef struct +{ + hci_transport_evt_type_t evt_type; /**< Type of event. */ +} hci_transport_evt_t; + +/**@brief Transport layer generic event callback function type. + * + * @param[in] event Transport layer event. + */ +typedef void (*hci_transport_event_handler_t)(hci_transport_evt_t event); + +/**@brief TX done event callback function result codes. */ +typedef enum +{ + HCI_TRANSPORT_TX_DONE_SUCCESS, /**< Transmission success, peer transport entity has acknowledged the transmission. */ + HCI_TRANSPORT_TX_DONE_FAILURE /**< Transmission failure. */ +} hci_transport_tx_done_result_t; + +/**@brief Transport layer TX done event callback function type. + * + * @param[in] result TX done event result code. + */ +typedef void (*hci_transport_tx_done_handler_t)(hci_transport_tx_done_result_t result); + +/**@brief Function for registering a generic event handler. + * + * @note Multiple registration requests will overwrite any possible existing registration. + * + * @param[in] event_handler The function to be called by the transport layer upon an event. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + */ +uint32_t hci_transport_evt_handler_reg(hci_transport_event_handler_t event_handler); + +/**@brief Function for registering a handler for TX done event. + * + * @note Multiple registration requests will overwrite any possible existing registration. + * + * @param[in] event_handler The function to be called by the transport layer upon TX done + * event. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + */ +uint32_t hci_transport_tx_done_register(hci_transport_tx_done_handler_t event_handler); + +/**@brief Function for opening the transport channel and initializing the transport layer. + * + * @warning Must not be called for a channel which has been allready opened. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_INTERNAL Operation failure. Internal error ocurred. + */ +uint32_t hci_transport_open(void); + +/**@brief Function for closing the transport channel. + * + * @note Can be called multiple times and also for not opened channel. + * + * @retval NRF_SUCCESS Operation success. + */ +uint32_t hci_transport_close(void); + +/**@brief Function for allocating tx packet memory. + * + * @param[out] pp_memory Pointer to the packet data. + * + * @retval NRF_SUCCESS Operation success. Memory was allocated. + * @retval NRF_ERROR_NO_MEM Operation failure. No memory available. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + */ +uint32_t hci_transport_tx_alloc(uint8_t ** pp_memory); + +/**@brief Function for freeing tx packet memory. + * + * @note Memory management works in FIFO principle meaning that free order must match the alloc + * order. + * + * @retval NRF_SUCCESS Operation success. Memory was freed. + */ +uint32_t hci_transport_tx_free(void); + +/**@brief Function for writing a packet. + * + * @note Completion of this method does not guarantee that actual peripheral transmission would + * have completed. + * + * @note In case of 0 byte packet length write request, message will consist of only transport + * module specific headers. + * + * @retval NRF_SUCCESS Operation success. Packet was added to the transmission queue + * and an event will be send upon transmission completion. + * @retval NRF_ERROR_NO_MEM Operation failure. Transmission queue is full and packet was not + * added to the transmission queue. User should wait for + * a appropriate event prior issuing this operation again. + * @retval NRF_ERROR_DATA_SIZE Operation failure. Packet size exceeds limit. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + * @retval NRF_ERROR_INVALID_STATE Operation failure. Channel is not open. + */ +uint32_t hci_transport_pkt_write(const uint8_t * p_buffer, uint32_t length); + +/**@brief Function for extracting received packet. + * + * @note Extracted memory can't be reused by the underlying transport layer untill freed by call to + * hci_transport_rx_pkt_consume(). + * + * @param[out] pp_buffer Pointer to the packet data. + * @param[out] p_length Length of packet data in bytes. + * + * @retval NRF_SUCCESS Operation success. Packet was extracted. + * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to extract. + * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. + */ +uint32_t hci_transport_rx_pkt_extract(uint8_t ** pp_buffer, uint32_t * p_length); + +/**@brief Function for consuming extracted packet described by p_buffer. + * + * RX memory pointed to by p_buffer is freed and can be reused by the underlying transport layer. + * + * @param[in] p_buffer Pointer to the buffer that has been consumed. + * + * @retval NRF_SUCCESS Operation success. + * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to consume. + * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer. + */ +uint32_t hci_transport_rx_pkt_consume(uint8_t * p_buffer); + +#endif // HCI_TRANSPORT_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/pstorage.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/pstorage.h new file mode 100644 index 0000000000..c76e59fd97 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/app_common/pstorage.h @@ -0,0 +1,334 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/**@file + * + * @defgroup persistent_storage Persistent Storage Interface + * @{ + * @ingroup app_common + * @brief Abstracted flash interface. + * + * @details In order to ensure that the SDK and application be moved to alternate persistent storage + * options other than the default provided with NRF solution, an abstracted interface is provided + * by the module to ensure SDK modules and application can be ported to alternate option with ease. + */ + +#ifndef PSTORAGE_H__ +#define PSTORAGE_H__ + +#include "nordic_global.h" +#include "pstorage_platform.h" + + +/**@defgroup ps_opcode Persistent Storage Access Operation Codes + * @{ + * @brief Persistent Storage Access Operation Codes. These are used to report any error during + * a persistent storage access operation or any general error that may occur in the + * interface. + * + * @details Persistent Storage Access Operation Codes used in error notification callback + * registered with the interface to report any error during an persistent storage access + * operation or any general error that may occur in the interface. + */ + #define PSTORAGE_ERROR_OP_CODE 0x01 /**< General Error Code */ + #define PSTORAGE_STORE_OP_CODE 0x02 /**< Error when Store Operation was requested */ + #define PSTORAGE_LOAD_OP_CODE 0x03 /**< Error when Load Operation was requested */ + #define PSTORAGE_CLEAR_OP_CODE 0x04 /**< Error when Clear Operation was requested */ + +/**@} */ + +/**@defgroup pstorage_data_types Persistent Memory Interface Data Types + * @{ + * @brief Data Types needed for interfacing with persistent memory. + * + * @details Data Types needed for interfacing with persistent memory. + */ + +/**@brief Persistent Storage Error Reporting Callback + * + * @details Persistent Storage Error Reporting Callback that is used by the interface to report + * success or failure of a flash operation. Therefore, for store operation or clear + * operations, that take time, application can know when the procedure was complete. + * For store operation, since no data copy is made, receiving a success or failure + * notification, indicated by the reason parameter of callback is an indication that + * the resident memory could now be reused or freed, as the case may be. + * This callback is not received for load operation. + * + * @param handle Identifies module and block for which callback is received. + * @param op_code Identifies the operation for which the event is notified. + * @param result Identifies the result of flash access operation. + * NRF_SUCCESS implies, operation succeeded. + * @param p_data Identifies the application data pointer. In case of store operation, this points + * to the resident source of application memory that application can now free or + * reuse. In case of clear, this is NULL as no application pointer is needed for + * this operation. + * @param data_len Length data application had provided for the operation. + * + */ +typedef void (*pstorage_ntf_cb_t)(pstorage_handle_t * p_handle, + uint8_t op_code, + uint32_t result, + uint8_t * p_data, + uint32_t data_len); + + +typedef struct ps_module_param +{ + + pstorage_ntf_cb_t cb; /**< Callback registered with the module to be notified of any error occurring in persistent memory management */ + pstorage_size_t block_size; /**< Desired block size for persistent memory storage, for example, if a module has a table with 10 entries, each entry is size 64 bytes, + * it can request 10 blocks with block size 64 bytes. On the other hand, the module can also request one block of size 640 based on + * how it would like to access or alter memory in persistent memory. + * First option is preferred when single entries that need to be updated often when having no impact on the other entries. + * While second option is preferred when entries of table are not changed on individually but have common point of loading and storing + * data. + */ + pstorage_size_t block_count; /** Number of blocks requested by the module, minimum values is 1. */ + +} pstorage_module_param_t; + +/**@} */ + +/**@defgroup pstorage_routines Persistent Storage Access Routines + * @{ + * @brief Functions/Interface SDK modules use to persistently store data. + * + * @details Interface for Application & SDK module to load/store information persistently. + * Note: that while implementation of each of the persistent storage access function + * depends on the system and can specific to system/solution, the signature of the + * interface routines should not be altered. + */ + +/**@brief Module Initialization Routine. + * + * @details Initializes module. To be called once before any other APIs of the module are used. + * + * @retval NRF_SUCCESS on success, otherwise an appropriate error code. + */ +uint32_t pstorage_init(void); + + +/**@brief Register with persistent storage interface. + * + * @param[in] p_module_param Module registration param. + * @param[out] p_block_id Block identifier to identify persistent memory blocks in case registration + * succeeds. Application is expected to use the block ids for subsequent operations on + * requested persistent memory. Maximum registrations permitted is determined by + * configuration parameter PSTORAGE_MAX_APPLICATIONS. + * In case more than one memory blocks are requested, the identifier provided here is + * the base identifier for the first block and to identify subsequent block, + * application shall use \@ref pstorage_block_identifier_get with this base identifier + * and block number. Therefore if 10 blocks of size 64 are requested and application + * wishes to store memory in 6th block, it shall use + * \@ref pstorage_block_identifier_get with based id and provide a block number of 5. + * This way application is only expected to remember the base block identifier. + * + * @retval NRF_SUCCESS on success, otherwise an appropriate error code. + * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization. + * @retval NRF_ERROR_NULL if NULL parameter has been passed. + * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API. + * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported. + */ +uint32_t pstorage_register(pstorage_module_param_t * p_module_param, + pstorage_handle_t* p_block_id); + + +/** + * @brief Function to get block id with reference to base block identifier provided at time of + * registration. + * + * @details Function to get block id with reference to base block identifier provided at time of + * registration. + * In case more than one memory blocks were requested when registering, the identifier + * provided here is the base identifier for the first block and to identify subsequent + * block, application shall use this routine to get block identifier providing input as + * base identifier and block number. Therefore if 10 blocks of size 64 are requested and + * application wishes to store memory in 6th block, it shall use + * \@ref pstorage_block_identifier_get with based id and provide a block number of 5. + * This way application is only expected to remember the base block identifier. + * + * @param[in] p_base_id Base block id received at the time of registration. + * @param[in] block_num Block Number, with first block numbered zero. + * @param[out] p_block_id Block identifier for the block number requested in case the API succeeds. + * + * @retval NRF_SUCCESS on success, else an error code indicating reason for failure. + * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization. + * @retval NRF_ERROR_NULL if NULL parameter has been passed. + * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API. + */ +uint32_t pstorage_block_identifier_get(pstorage_handle_t * p_base_id, + pstorage_size_t block_num, + pstorage_handle_t * p_block_id); + + +/**@brief Routine to persistently store data of length 'size' contained in 'p_src' address + * in storage module at 'p_dest' address; Equivalent to Storage Write. + * + * @param[in] p_dest Destination address where data is to be stored persistently. + * @param[in] p_src Source address containing data to be stored. API assumes this to be resident + * memory and no intermediate copy of data is made by the API. + * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned. + * @param[in] offset Offset in bytes to be applied when writing to the block. + * For example, if within a block of 100 bytes, application wishes to + * write 20 bytes at offset of 12, then this field should be set to 12. + * Should be word aligned. + * + * @retval NRF_SUCCESS on success, otherwise an appropriate error code. + * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization. + * @retval NRF_ERROR_NULL if NULL parameter has been passed. + * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API. + * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned. + * @retval NRF_ERROR_NO_MEM in case request cannot be processed. + * + * @warning No copy of the data is made, and hence memory provided for data source to be written + * to flash cannot be freed or reused by the application until this procedure + * is complete. End of this procedure is notified to the application using the + * notification callback registered by the application. + */ +uint32_t pstorage_store(pstorage_handle_t * p_dest, + uint8_t * p_src, + pstorage_size_t size, + pstorage_size_t offset); + + +/**@brief Routine to load persistently stored data of length 'size' from 'p_src' address + * to 'p_dest' address; Equivalent to Storage Read. + * + * @param[in] p_dest Destination address where persistently stored data is to be loaded. + * @param[in] p_src Source from where data is to be loaded from persistent memory. + * @param[in] size Size of data to be loaded from persistent memory expressed in bytes. + * Should be word aligned. + * @param[in] offset Offset in bytes to be applied when loading from the block. + * For example, if within a block of 100 bytes, application wishes to + * load 20 bytes from offset of 12, then this field should be set to 12. + * Should be word aligned. + * + * + * @retval NRF_SUCCESS on success, otherwise an appropriate error code. + * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization. + * @retval NRF_ERROR_NULL if NULL parameter has been passed. + * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API. + * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned. + */ +uint32_t pstorage_load(uint8_t * p_dest, + pstorage_handle_t * p_src, + pstorage_size_t size, + pstorage_size_t offset); + + +/**@brief Routine to clear data in persistent memory. + * + * @param[in] p_base_id Base block identifier in persistent memory that needs to cleared; + * Equivalent to an Erase Operation. + * + * @param[in] size Size of data to be cleared from persistent memory expressed in bytes. + * This is currently unused. And a clear would mean clearing all blocks, + * however, this parameter is to provision for clearing of certain blocks + * of memory only and not all if need be. + * + * @retval NRF_SUCCESS on success, otherwise an appropriate error code. + * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization. + * @retval NRF_ERROR_NULL if NULL parameter has been passed. + * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API. + * @retval NRF_ERROR_NO_MEM in case request cannot be processed. + * + * @note Clear operations may take time. This API however, does not block until the clear + * procedure is complete. Application is notified of procedure completion using + * notification callback registered by the application. 'result' parameter of the + * callback suggests if the procedure was successful or not. + */ +uint32_t pstorage_clear(pstorage_handle_t * p_base_id, pstorage_size_t size); + +#ifdef PSTORAGE_RAW_MODE_ENABLE + +/**@brief Function for registering with persistent storage interface. + * + * @param[in] p_module_param Module registration param. + * @param[out] p_block_id Block identifier to identify persistent memory blocks in case + * registration succeeds. Application is expected to use the block ids for subsequent + * operations on requested persistent memory. + * In case more than one memory blocks are requested, the identifier provided here is + * the base identifier for the first block and to identify subsequent block, + * application shall use \@ref pstorage_block_identifier_get with this base identifier + * and block number. Therefore if 10 blocks of size 64 are requested and application + * wishes to store memory in 6th block, it shall use + * \@ref pstorage_block_identifier_get with based id and provide a block number of 5. + * This way application is only expected to remember the base block identifier. + * + * @retval NRF_SUCCESS on success, otherwise an appropriate error code. + * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization. + * @retval NRF_ERROR_NULL if NULL parameter has been passed. + * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API. + * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported. + */ +uint32_t pstorage_raw_register(pstorage_module_param_t * p_module_param, + pstorage_handle_t * p_block_id); + +/**@brief Raw mode function for persistently storing data of length 'size' contained in 'p_src' + * address in storage module at 'p_dest' address; Equivalent to Storage Write. + * + * @param[in] p_dest Destination address where data is to be stored persistently. + * @param[in] p_src Source address containing data to be stored. API assumes this to be resident + * memory and no intermediate copy of data is made by the API. + * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned. + * @param[in] offset Offset in bytes to be applied when writing to the block. + * For example, if within a block of 100 bytes, application wishes to + * write 20 bytes at offset of 12, then this field should be set to 12. + * Should be word aligned. + * + * @retval NRF_SUCCESS on success, otherwise an appropriate error code. + * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization. + * @retval NRF_ERROR_NULL if NULL parameter has been passed. + * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API. + * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned. + * @retval NRF_ERROR_NO_MEM in case request cannot be processed. + * + * @warning No copy of the data is made, and hence memory provided for data source to be written + * to flash cannot be freed or reused by the application until this procedure + * is complete. End of this procedure is notified to the application using the + * notification callback registered by the application. + */ +uint32_t pstorage_raw_store(pstorage_handle_t * p_dest, + uint8_t * p_src, + pstorage_size_t size, + pstorage_size_t offset); + +/**@brief Function for clearing data in persistent memory in raw mode. + * + * @param[in] p_base_id Base block identifier in persistent memory that needs to cleared; + * Equivalent to an Erase Operation. + * + * @param[in] size Size of data to be cleared from persistent memory expressed in bytes. + * This is currently unused. And a clear would mean clearing all blocks, + * however, this parameter is to provision for clearing of certain blocks + * of memory only and not all if need be. + * + * @retval NRF_SUCCESS on success, otherwise an appropriate error code. + * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization. + * @retval NRF_ERROR_NULL if NULL parameter has been passed. + * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API. + * @retval NRF_ERROR_NO_MEM in case request cannot be processed. + * + * @note Clear operations may take time. This API however, does not block until the clear + * procedure is complete. Application is notified of procedure completion using + * notification callback registered by the application. 'result' parameter of the + * callback suggests if the procedure was successful or not. + */ +uint32_t pstorage_raw_clear(pstorage_handle_t * p_dest, pstorage_size_t size); + +#endif // PSTORAGE_RAW_MODE_ENABLE + +/**@} */ +/**@} */ + +#endif // PSTORAGE_H__ + diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_advdata.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_advdata.h new file mode 100644 index 0000000000..a906bae0d0 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_advdata.h @@ -0,0 +1,114 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_sdk_lib_advdata Advertising Data Encoder + * @{ + * @ingroup ble_sdk_lib + * @brief Function for encoding the advertising data and/or scan response data, and passing them to + * the stack. + */ + +#ifndef BLE_ADVDATA_H__ +#define BLE_ADVDATA_H__ + +#include +#include +#include +#include "nordic_global.h" +#include "ble.h" +#include "app_util.h" + +/**@brief Advertising data name type. This contains the options available for the device name inside + * the advertising data. */ +typedef enum +{ + BLE_ADVDATA_NO_NAME, /**< Include no device name in advertising data. */ + BLE_ADVDATA_SHORT_NAME, /**< Include short device name in advertising data. */ + BLE_ADVDATA_FULL_NAME /**< Include full device name in advertising data. */ +} ble_advdata_name_type_t; + +/**@brief UUID list type. */ +typedef struct +{ + uint16_t uuid_cnt; /**< Number of UUID entries. */ + ble_uuid_t * p_uuids; /**< Pointer to UUID array entries. */ +} ble_advdata_uuid_list_t; + +/**@brief Connection interval range structure. */ +typedef struct +{ + uint16_t min_conn_interval; /**< Minimum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). */ + uint16_t max_conn_interval; /**< Maximum Connection Interval, in units of 1.25ms, range 6 to 3200 (i.e. 7.5ms to 4s). Value of 0xFFFF indicates no specific maximum. */ +} ble_advdata_conn_int_t; + +/**@brief Manufacturer specific data structure. */ +typedef struct +{ + uint16_t company_identifier; /**< Company Identifier Code. */ + uint8_array_t data; /**< Additional manufacturer specific data. */ +} ble_advdata_manuf_data_t; + +/**@brief Service data structure. */ +typedef struct +{ + uint16_t service_uuid; /**< Service UUID. */ + uint8_array_t data; /**< Additional service data. */ +} ble_advdata_service_data_t; + +/**@brief Advertising data structure. This contains all options and data needed for encoding and + * setting the advertising data. */ +typedef struct +{ + ble_advdata_name_type_t name_type; /**< Type of device name. */ + uint8_t short_name_len; /**< Length of short device name (if short type is specified). */ + bool include_appearance; /**< Determines if Appearance shall be included. */ + uint8_array_t flags; /**< Advertising data Flags field. */ + int8_t * p_tx_power_level; /**< TX Power Level field. */ + ble_advdata_uuid_list_t uuids_more_available; /**< List of UUIDs in the 'More Available' list. */ + ble_advdata_uuid_list_t uuids_complete; /**< List of UUIDs in the 'Complete' list. */ + ble_advdata_uuid_list_t uuids_solicited; /**< List of solcited UUIDs. */ + ble_advdata_conn_int_t * p_slave_conn_int; /**< Slave Connection Interval Range. */ + ble_advdata_manuf_data_t * p_manuf_specific_data; /**< Manufacturer specific data. */ + ble_advdata_service_data_t * p_service_data_array; /**< Array of Service data structures. */ + uint8_t service_data_count; /**< Number of Service data structures. */ +} ble_advdata_t; + +/**@brief Function for encoding and setting the advertising data and/or scan response data. + * + * @details This function encodes advertising data and/or scan response data based on the selections + * in the supplied structures, and passes the encoded data to the stack. + * + * @param[in] p_advdata Structure for specifying the content of the advertising data. + * Set to NULL if advertising data is not to be set. + * @param[in] p_srdata Structure for specifying the content of the scan response data. + * Set to NULL if scan response data is not to be set. + * + * @return NRF_SUCCESS on success, NRF_ERROR_DATA_SIZE if not all the requested data could fit + * into the advertising packet. The maximum size of the advertisement packet is @ref + * BLE_GAP_ADV_MAX_SIZE. + * + * @warning This API may override application's request to use the long name and use a short name + * instead. This truncation will occur in case the long name does not fit advertisement data size. + * Application is permitted to specify a preferred short name length in case truncation is required. + * For example, if the complete device name is ABCD_HRMonitor, application can specify short name + * length to 8 such that short device name appears as ABCD_HRM instead of ABCD_HRMo or ABCD_HRMoni + * etc if available size for short name is 9 or 12 respectively to have more apporpriate short name. + * However, it should be noted that this is just a preference that application can specify and + * if the preference too large to fit in Advertisement Data, this can be further truncated. + */ +uint32_t ble_advdata_set(const ble_advdata_t * p_advdata, const ble_advdata_t * p_srdata); + +#endif // BLE_ADVDATA_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_advdata_parser.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_advdata_parser.h new file mode 100644 index 0000000000..b0f7bbc8f3 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_advdata_parser.h @@ -0,0 +1,10 @@ +#ifndef BLE_ADVDATA_PARSER_H_ +#define BLE_ADVDATA_PARSER_H_ + +#include "nordic_global.h" +#include "ble_advdata.h" + +uint32_t ble_advdata_parse(uint8_t * p_data, uint8_t len, ble_advdata_t * advdata); +uint32_t ble_advdata_parser_field_find(uint8_t type, uint8_t * p_advdata, uint8_t * len, uint8_t ** pp_field_data); + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_bondmngr.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_bondmngr.h new file mode 100644 index 0000000000..1416568107 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_bondmngr.h @@ -0,0 +1,339 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_sdk_lib_bond_manager Bonds and Persistent Data Manager + * @{ + * @ingroup ble_sdk_lib + * @brief This module handles multiple bonds and persistent attributes. + * + * @details When using Bluetooth low energy, a central device and a peripheral device can + * exchange identification information which they are capable of storing in memory (for + * example, in non-volatile memory). This information can be used for identity verification + * between the devices when they reconnect in the future. This relationship is known as a + * 'bond'. + * + * Bonding Information: + * + * The S110 SoftDevice handles the BLE on-air transactions necessary to establish a new + * bond or to use a previous bond when it reconnects to a bonded central. It is however up + * to the application layer to memorize the identification information between + * connections and to provide them back to the S110 stack when it detects a re-connection + * from a previously bonded central. This identification information is referred to as + * Bonding Information in code and the SDK. + * + * System Attributes: + * + * If the application is a GATT server, it stores a set of persistent attributes related + * to a connection when bonding with a central. On reconnection with the known bonded + * central, the application restores the related persistent attributes in the last known + * state back to the S110 SoftDevice. These persistent attributes mainly include the Client + * Characteristic Configuration Descriptor (or CCCD, see the Bluetooth + * Core Specification for more information) states and could include other attributes + * in the future. Persistent attributes are referred to as System Attributes in code and + * in the SDK documentation. + * + * An application can use the Bonds and Persistent Data Manager module (referred to as the + * bond manager) included in the nRF51 SDK to handle most of the operations related to + * the Bonding Information and System Attributes. The bond manager notifies the + * application when it's connected to a new bonded central or to a previously bonded central. + * The application can use the Bond Manager API to store or load (or restore) the + * Bonding Information and System Attributes. The bond manager identifies all the centrals + * the application is bonded to and restores their respective Bonding Information and + * System Attributes to the S110 stack. + * + * In addition, you can use the bond manager to set up your application to advertise: + * + * - To a given bonded central using directed advertisement. + * - To a list of bonded centrals - i.e. using whitelist. + * + * The bond manager automatically writes the Bonding Information to the flash memory when + * the bonding procedure to a new central is finished. Upon disconnection, the application + * should use the Bond Manager API @ref ble_bondmngr_bonded_centrals_store to write the + * latest Bonding Information and System Attributes to flash. + * + * The bond manager provides the API @ref ble_bondmngr_sys_attr_store to allow the + * application to write the System Attributes to flash while in a connection. Your + * application should call this API when it considers that all CCCDs and other persistent + * attributes are in a stable state. This API call will safely fail if System Attributes + * data for the current connected central is already present in the flash. The API does so + * because a flash write in such a situation would require an erase of flash, which takes a + * long time (21 milliseconds) to complete. This may disrupt the radio. + * + * Applications using the Bond Manager must have a configuration file named + * ble_bondmngr_cfg.h (see below for details). + * + * Refer to @ref ble_bond_mgr_msc to see the flow of events when connecting to a central + * using the Bond Manager + * + * + * @section ble_sdk_lib_bond_manager_cfg Configuration File + * Applications using the Bond Manager must have a configuration file named ble_bondmngr_cfg.h. + * Here is an example of this file: + * + * @code + * #ifndef BLE_BONDMNGR_CFG_H__ + * #define BLE_BONDMNGR_CFG_H__ + * + * #define BLE_BONDMNGR_CCCD_COUNT 1 + * #define BLE_BONDMNGR_MAX_BONDED_CENTRALS 4 + * + * #endif // BLE_BONDMNGR_CFG_H__ + * @endcode + * + * BLE_BONDMNGR_CCCD_COUNT is the number of CCCDs used in the application, and + * BLE_BONDMNGR_MAX_BONDED_CENTRALS is the maximum number of bonded centrals to be supported by the + * application. + */ + +#ifndef BLE_BONDMNGR_H__ +#define BLE_BONDMNGR_H__ + +#include +#include "nordic_global.h" +#include "ble.h" +#include "ble_srv_common.h" + + +/** @defgroup ble_bond_mgr_msc Message Sequence Charts + * @{ + * @brief Bond Manager interaction with S110 Stack + * @{ + * @defgroup UNBONDED_CENTRAL Connecting to an unbonded central + * @image html bond_manager_unbonded_master.jpg Connecting to an unbonded central + * @defgroup BONDED_CENTRAL Connecting to a bonded central + * @image html bond_manager_bonded_master.jpg Connecting to a bonded central + * @} + * @} + */ + +/** @defgroup DEFINES Defines + * @brief Macros defined by this module. + * @{ */ + +#define INVALID_CENTRAL_HANDLE (-1) /**< Invalid handle, used to indicate that the central is not a known bonded central. */ + +/** @} */ + +/** @defgroup ENUMS Enumerations + * @brief Enumerations defined by this module. + * @{ */ + +/**@brief Bond Manager Module event type. */ +typedef enum +{ + BLE_BONDMNGR_EVT_NEW_BOND, /**< New bond has been created. */ + BLE_BONDMNGR_EVT_CONN_TO_BONDED_CENTRAL, /**< Connected to a previously bonded central. */ + BLE_BONDMNGR_EVT_ENCRYPTED, /**< Current link is encrypted. */ + BLE_BONDMNGR_EVT_AUTH_STATUS_UPDATED, /**< Authentication status updated for current central. */ + BLE_BONDMNGR_EVT_BOND_FLASH_FULL /**< Flash block for storing Bonding Information is full. */ +} ble_bondmngr_evt_type_t; + +/** @} */ + + +/** @defgroup DATA_STRUCTURES Data Structures + * @brief Data Structures defined by this module. + * @{ */ + +/**@brief Bond Manager Module event. */ +typedef struct +{ + ble_bondmngr_evt_type_t evt_type; /**< Type of event. */ + int8_t central_handle; /**< Handle to the current central. This is an index to the central list maintained internally by the bond manager. */ + uint16_t central_id; /**< Identifier to the central. This will be the same as Encryption diversifier of the central (see @ref ble_gap_evt_sec_info_request_t). This value is constant for the duration of the bond. */ +} ble_bondmngr_evt_t; + +/** @} */ + +/** @defgroup TYPEDEFS Typedefs + * @brief Typedefs defined by this module. + * @{ */ + +/**@brief Bond Manager Module event handler type. */ +typedef void (*ble_bondmngr_evt_handler_t) (ble_bondmngr_evt_t * p_evt); + +/** @} */ + +/** @addtogroup DATA_STRUCTURES + * @{ */ + +/**@brief Bond Manager Module init structure. This contains all options and data needed for + * initialization of the Bond Manager module. */ +typedef struct +{ + uint8_t flash_page_num_bond; /**< Flash page number to use for storing Bonding Information. */ + uint8_t flash_page_num_sys_attr; /**< Flash page number to use for storing System Attributes. */ + bool bonds_delete; /**< TRUE if bonding and System Attributes for all centrals is to be deleted from flash during initialization, FALSE otherwise. */ + ble_bondmngr_evt_handler_t evt_handler; /**< Event handler to be called for handling events in bond manager. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ +} ble_bondmngr_init_t; + +/** @} */ + + +/** @defgroup FUNCTIONS Functions + * @brief Functions/APIs implemented and exposed by this module. + * @{ */ + +/**@brief Function for initializing the Bond Manager. + * + * @param[in] p_init This contains information needed to initialize this module. + * + * @return NRF_SUCCESS on successful initialization, otherwise an error code. + */ +uint32_t ble_bondmngr_init(ble_bondmngr_init_t * p_init); + +/**@brief Function for handling all events from the BLE stack that relate to this module. + * + * @param[in] p_ble_evt The event received from the BLE stack. + * + * @return NRF_SUCCESS if all operations went successfully, + * NRF_ERROR_NO_MEM if the maximum number of bonded centrals has been reached. + * Other error codes in other situations. + */ +void ble_bondmngr_on_ble_evt(ble_evt_t * p_ble_evt); + +/**@brief Function for storing the bonded centrals data including bonding info and System Attributes into + * flash memory. + * + * @details If the data to be written is different from the existing data, this function erases the + * flash pages before writing to flash. + * + * @warning This function could prevent the radio from running. Therefore it MUST be called ONLY + * when the application knows that the Bluetooth radio is not active. An example of + * such a state is when the application has received the Disconnected event and has not yet + * started advertising. If it is called in any other state, or if it is not called at + * all, the behavior is undefined. + * + * @return NRF_SUCCESS on success, an error_code otherwise. + */ +uint32_t ble_bondmngr_bonded_centrals_store(void); + +/**@brief Function for deleting the bonded central database from flash. + * + * @details After calling this function you should call ble_bondmngr_init() to re-initialize the + * RAM database. + * + * @return NRF_SUCCESS on success, an error_code otherwise. + */ +uint32_t ble_bondmngr_bonded_centrals_delete(void); + +/**@brief Function for getting the whitelist containing all currently bonded centrals. + * + * @details This function populates the whitelist with either the IRKs or the public adresses + * of all bonded centrals. + * + * @param[out] p_whitelist Whitelist structure with all bonded centrals. + * + * @return NRF_SUCCESS on success, an error_code otherwise. + */ +uint32_t ble_bondmngr_whitelist_get(ble_gap_whitelist_t * p_whitelist); + +/**@brief Function for getting the central's address corresponding to a given central_handle. + * + * @note This function returns NRF_ERROR_INVALID_PARAM if the given central has a private + * address. + * + * @param[in] central_handle Central's handle. + * @param[out] p_central_addr Pointer to the central's address which can be used for + * directed advertising. + */ +uint32_t ble_bondmngr_central_addr_get(int8_t central_handle, ble_gap_addr_t * p_central_addr); + +/**@brief Function for storing the System Attributes of a newly connected central. + * + * @details This function fetches the System Attributes of the current central from the stack, adds + * it to the database in memory, and also stores it in the flash (without erasing any + * flash page). + * This function is intended to facilitate the storage of System Attributes when connected + * to new central (whose System Attributes are NOT yet stored in flash) even in connected + * state without affecting radio link. This function can, for example, be called after the + * CCCD is written by a central. The function will succeed if the central is a new central. + * See @ref ble_sdk_app_hids_keyboard or @ref ble_sdk_app_hids_mouse for sample usage. + * + * @return NRF_SUCCESS on success, otherwise an error code. + * NRF_ERROR_INVALID_STATE is returned if the System Attributes of the current central is + * already present in the flash because it is a previously known central. + */ +uint32_t ble_bondmngr_sys_attr_store(void); + +/**@brief Function for fetching the identifiers of known centrals. + * + * @details This function fetches the identifiers of the centrals that are currently in the + * database, or in other words, known to the bond manager. + * + * @param[out] p_central_ids Pointer to the array of central identifiers. It is recommended + * that the length of this array be equal to + * MAX_NUMBER_OF_BONDED_CENTRALS * 2 bytes. If value of this pointer + * is NULL, only the number of centrals in the database will be + * filled in p_length. This can be used to find out the + * required size of the array pointed to by p_central_ids in + * a subsequent call. + * @param[in, out] p_length Pointer to the length of p_central_ids array provided as + * input. On return, this function will write the number of central + * identifiers found to p_length + * + * @return NRF_SUCCESS on success. + * NRF_ERROR_NULL if the input parameter p_length is NULL. + * NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized. + * NRF_ERROR_DATA_SIZE is returned if the length of the input parameter + * p_central_ids provided is not enough to fit in all the central identifiers in the + * database. + */ +uint32_t ble_bondmngr_central_ids_get(uint16_t * p_central_ids, uint16_t * p_length); + +/**@brief Function for deleting a single central from the database. + * @details This function deletes the Bonding Information and System Attributes of a single + * central from the flash. + * The application can use the @ref ble_bondmngr_central_ids_get function to fetch the + * identifiers of centrals present in the database and then call this function. + * + * @warning This function could prevent the radio from running. Therefore it MUST be called ONLY + * when the application knows that the Bluetooth radio is not active. An example + * of such a state could be when the application is not in a connected state AND is + * also not advertising. If it is called in any other state, the behavior is + * undefined. + * + * @param[in] central_id Identifier of the central to be deleted. + * + * @return NRF_SUCCESS on success. + * NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized. + * NRF_ERROR_NOT_FOUND if the central with the given identifier is not found in the + * database. + */ +uint32_t ble_bondmngr_bonded_central_delete(uint16_t central_id); + +/**@brief Function to verify encryption status link with bonded central is encrypted or not. + * @details This function provides status of encrption of the link with a bonded central. + * Its is recommended that the application can use the + * @ref ble_bondmngr_central_ids_get function to verify if the central is in the + * database and then call this function. + * + * @warning Currently the central id paramater is unused and is added only for future extension. + * As, today only one link is permitted for the peripheral device, status of current + * link is provided. In future, with more possibilities in the topology, central_id + * will be needed to identify the central. + * + * @param[out] status Status of encryption, true implies link encrypted. + * + * @return NRF_SUCCESS on success. + * NRF_ERROR_INVALID_STATE is returned if the bond manager was not initialized. + */ +uint32_t ble_bondmngr_is_link_encrypted(bool * status); + +/** @} */ + +#endif // BLE_BONDMNGR_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_central_bondmngr.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_central_bondmngr.h new file mode 100644 index 0000000000..17cbf00a70 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_central_bondmngr.h @@ -0,0 +1,26 @@ +#ifndef __BLE_CENTRAL_BONDMNGR_H_ +#define __BLE_CENTRAL_BONDMNGR_H_ + +#include "nordic_global.h" +#include "ble.h" +#include "ble_gap.h" + +#include +#include + +typedef struct +{ + ble_gap_sec_params_t * p_sec_params; +} ble_central_bondmngr_t; + +typedef struct +{ + ble_gap_sec_params_t * p_sec_params; + bool delete_bonds; +} ble_central_bondmngr_init_t; + +uint32_t ble_central_bondmngr_init(ble_central_bondmngr_t * p_bm, ble_central_bondmngr_init_t * p_bm_init); +void ble_central_bondmngr_on_ble_evt(ble_central_bondmngr_t * p_bm, ble_evt_t * p_ble_evt); +uint32_t ble_central_bondmngr_store(ble_central_bondmngr_t * p_bm); + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_conn_params.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_conn_params.h new file mode 100644 index 0000000000..d0c7463d8a --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_conn_params.h @@ -0,0 +1,112 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_sdk_lib_conn_params Connection Parameters Negotiation + * @{ + * @ingroup ble_sdk_lib + * @brief Module for initiating and executing a connection parameters negotiation procedure. + */ + +#ifndef BLE_CONN_PARAMS_H__ +#define BLE_CONN_PARAMS_H__ + +#include +#include "nordic_global.h" +#include "ble.h" +#include "ble_srv_common.h" + +/**@brief Connection Parameters Module event type. */ +typedef enum +{ + BLE_CONN_PARAMS_EVT_FAILED , /**< Negotiation procedure failed. */ + BLE_CONN_PARAMS_EVT_SUCCEEDED /**< Negotiation procedure succeeded. */ +} ble_conn_params_evt_type_t; + +/**@brief Connection Parameters Module event. */ +typedef struct +{ + ble_conn_params_evt_type_t evt_type; /**< Type of event. */ +} ble_conn_params_evt_t; + +/**@brief Connection Parameters Module event handler type. */ +typedef void (*ble_conn_params_evt_handler_t) (ble_conn_params_evt_t * p_evt); + +/**@brief Connection Parameters Module init structure. This contains all options and data needed for + * initialization of the connection parameters negotiation module. */ +typedef struct +{ + ble_gap_conn_params_t * p_conn_params; /**< Pointer to the connection parameters desired by the application. When calling ble_conn_params_init, if this parameter is set to NULL, the connection parameters will be fetched from host. */ + uint32_t first_conn_params_update_delay; /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (in number of timer ticks). */ + uint32_t next_conn_params_update_delay; /**< Time between each call to sd_ble_gap_conn_param_update after the first (in number of timer ticks). Recommended value 30 seconds as per BLUETOOTH SPECIFICATION Version 4.0. */ + uint8_t max_conn_params_update_count; /**< Number of attempts before giving up the negotiation. */ + uint16_t start_on_notify_cccd_handle; /**< If procedure is to be started when notification is started, set this to the handle of the corresponding CCCD. Set to BLE_GATT_HANDLE_INVALID if procedure is to be started on connect event. */ + bool disconnect_on_fail; /**< Set to TRUE if a failed connection parameters update shall cause an automatic disconnection, set to FALSE otherwise. */ + ble_conn_params_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Battery Service. */ + ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ +} ble_conn_params_init_t; + + +/**@brief Function for initializing the Connection Parameters module. + * + * @note If the negotiation procedure should be triggered when notification/indication of + * any characteristic is enabled by the peer, then this function must be called after + * having initialized the services. + * + * @param[in] p_init This contains information needed to initialize this module. + * + * @return NRF_SUCCESS on successful initialization, otherwise an error code. + */ +uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init); + +/**@brief Function for stopping the Connection Parameters module. + * + * @details This function is intended to be used by the application to clean up the connection + * parameters update module. This will stop the connection parameters update timer if + * running, thereby preventing any impending connection parameters update procedure. This + * function must be called by the application when it needs to clean itself up (for + * example, before disabling the bluetooth SoftDevice) so that an unwanted timer expiry + * event can be avoided. + * + * @return NRF_SUCCESS on successful initialization, otherwise an error code. + */ +uint32_t ble_conn_params_stop(void); + +/**@brief Function for changing the current connection parameters to a new set. + * + * @details Use this function to change the connection parameters to a new set of parameter + * (ie different from the ones given at init of the module). + * This function is usefull for scenario where most of the time the application + * needs a relatively big connection interval, and just sometimes, for a temporary + * period requires shorter connection interval, for example to transfer a higher + * amount of data. + * If the given parameters does not match the current connection's parameters + * this function initiates a new negotiation. + * + * @param[in] new_params This contains the new connections parameters to setup. + * + * @return NRF_SUCCESS on successful initialization, otherwise an error code. + */ +uint32_t ble_conn_params_change_conn_params(ble_gap_conn_params_t *new_params); + +/**@brief Function for handling the Application's BLE Stack events. + * + * @details Handles all events from the BLE stack that are of interest to this module. + * + * @param[in] p_ble_evt The event received from the BLE stack. + */ +void ble_conn_params_on_ble_evt(ble_evt_t * p_ble_evt); + +#endif // BLE_CONN_PARAMS_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_date_time.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_date_time.h new file mode 100644 index 0000000000..6e323004c1 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_date_time.h @@ -0,0 +1,77 @@ +/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. +* +* The information contained herein is property of Nordic Semiconductor ASA. +* Terms and conditions of usage are described in detail in NORDIC +* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. +* +* Licensees are granted free, non-transferable use of the information. NO +* WARRANTY of ANY KIND is provided. This heading must NOT be removed from +* the file. +*/ + +/* Attention! +* To maintain compliance with Nordic Semiconductor ASA�s Bluetooth profile +* qualification listings, this section of source code must not be modified. +*/ + +/** @file + * @brief Contains definition of ble_date_time structure. + */ + +/** @file + * + * @defgroup ble_sdk_srv_date_time BLE Date Time characteristic type + * @{ + * @ingroup ble_sdk_srv + * @brief Definition of ble_date_time_t type. + */ + +#ifndef BLE_DATE_TIME_H__ +#define BLE_DATE_TIME_H__ + +#include +#include "nordic_global.h" + +/**@brief Date and Time structure. */ +typedef struct +{ + uint16_t year; + uint8_t month; + uint8_t day; + uint8_t hours; + uint8_t minutes; + uint8_t seconds; +} ble_date_time_t; + +static __INLINE uint8_t ble_date_time_encode(const ble_date_time_t * p_date_time, + uint8_t * p_encoded_data) +{ + uint8_t len = uint16_encode(p_date_time->year, p_encoded_data); + + p_encoded_data[len++] = p_date_time->month; + p_encoded_data[len++] = p_date_time->day; + p_encoded_data[len++] = p_date_time->hours; + p_encoded_data[len++] = p_date_time->minutes; + p_encoded_data[len++] = p_date_time->seconds; + + return len; +} + +static __INLINE uint8_t ble_date_time_decode(ble_date_time_t * p_date_time, + const uint8_t * p_encoded_data) +{ + uint8_t len = sizeof(uint16_t); + + p_date_time->year = uint16_decode(p_encoded_data); + p_date_time->month = p_encoded_data[len++]; + p_date_time->day = p_encoded_data[len++]; + p_date_time->hours = p_encoded_data[len++]; + p_date_time->minutes = p_encoded_data[len++]; + p_date_time->seconds = p_encoded_data[len++]; + + return len; +} + +#endif // BLE_DATE_TIME_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_debug_assert_handler.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_debug_assert_handler.h new file mode 100644 index 0000000000..eec0bbfcff --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_debug_assert_handler.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_debug_assert_handler Assert Handler for debug purposes. + * @{ + * @ingroup ble_sdk_lib + * @brief Module for handling of assert during application development when debugging. + * + * @details This module may be used during development of an application to facilitate debugging. + * It contains a function to write file name, line number and the Stack Memory to flash. + * This module is ONLY for debugging purposes and must never be used in final product. + * + */ + +#ifndef BLE_DEBUG_ASSERT_HANDLER_H__ +#define BLE_DEBUG_ASSERT_HANDLER_H__ + +#include +#include "nordic_global.h" + +/**@brief Function for handling the Debug assert, which can be called from an error handler. + * To be used only for debugging purposes. + * + *@details This code will copy the filename and line number into local variables for them to always + * be accessible in Keil debugger. The function will also write the ARM Cortex-M0 stack + * memory into flash where it can be retrieved and manually un-winded in order to + * back-trace the location where the error ocured.
+ * @warning ALL INTERRUPTS WILL BE DISABLED. + * + * @note This function will never return but loop forever for debug purposes. + * + * @param[in] error_code Error code supplied to the handler. + * @param[in] line_num Line number where the original handler is called. + * @param[in] p_file_name Pointer to the file name. + */ +void ble_debug_assert_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); + +#endif /* BLE_DEBUG_ASSERT_HANDLER_H__ */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_dtm.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_dtm.h new file mode 100644 index 0000000000..013e0b0f99 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_dtm.h @@ -0,0 +1,142 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_sdk_dtmlib_dtm DTM - Direct Test Mode + * @{ + * @ingroup ble_sdk_lib + * @brief Module for testing RF/PHY using DTM commands. + */ + +#ifndef BLE_DTM_H__ +#define BLE_DTM_H__ + +#include +#include +#include "nordic_global.h" + + +/**@brief Configuration parameters. */ +#define DEFAULT_TX_POWER RADIO_TXPOWER_TXPOWER_Pos4dBm /**< Default Transmission power using in the DTM module. */ +#define DEFAULT_TIMER NRF_TIMER0 /**< Default timer used for timing. */ +#define DEFAULT_TIMER_IRQn TIMER0_IRQn /**< IRQ used for timer. NOTE: MUST correspond to DEFAULT_TIMER. */ + +/**@brief BLE DTM command codes. */ +typedef uint32_t dtm_cmd_t; /**< DTM command type. */ + +#define LE_RESET 0 /**< DTM command: Reset device. */ +#define LE_RECEIVER_TEST 1 /**< DTM command: Start receive test. */ +#define LE_TRANSMITTER_TEST 2 /**< DTM command: Start transmission test. */ +#define LE_TEST_END 3 /**< DTM command: End test and send packet report. */ + +// Configuration options used as parameter 2 +// when cmd == LE_TRANSMITTER_TEST and payload == DTM_PKT_VENDORSPECIFIC +// Configuration value, if any, is supplied in parameter 3 + +#define CARRIER_TEST 0 /**< Length=0 indicates a constant, unmodulated carrier until LE_TEST_END or LE_RESET */ +#define CARRIER_TEST_STUDIO 1 /**< nRFgo Studio uses value 1 in length field, to indicate a constant, unmodulated carrier until LE_TEST_END or LE_RESET */ +#define SET_TX_POWER 2 /**< Set transmission power, value -40..+4 dBm in steps of 4 */ +#define SELECT_TIMER 3 /**< Select on of the 16 MHz timers 0, 1 or 2 */ + +#define LE_PACKET_REPORTING_EVENT 0x8000 /**< DTM Packet reporting event, returned by the device to the tester. */ +#define LE_TEST_STATUS_EVENT_SUCCESS 0x0000 /**< DTM Status event, indicating success. */ +#define LE_TEST_STATUS_EVENT_ERROR 0x0001 /**< DTM Status event, indicating an error. */ + +#define DTM_PKT_PRBS9 0x00 /**< Bit pattern PRBS9. */ +#define DTM_PKT_0X0F 0x01 /**< Bit pattern 11110000 (LSB is the leftmost bit). */ +#define DTM_PKT_0X55 0x02 /**< Bit pattern 10101010 (LSB is the leftmost bit). */ +#define DTM_PKT_VENDORSPECIFIC 0xFFFFFFFF /**< Vendor specific. Nordic: Continuous carrier test, or configuration. */ + +/**@brief Return codes from dtm_cmd(). */ +#define DTM_SUCCESS 0x00 /**< Indicate that the DTM function completed with success. */ +#define DTM_ERROR_ILLEGAL_CHANNEL 0x01 /**< Physical channel number must be in the range 0..39. */ +#define DTM_ERROR_INVALID_STATE 0x02 /**< Sequencing error: Command is not valid now. */ +#define DTM_ERROR_ILLEGAL_LENGTH 0x03 /**< Payload size must be in the range 0..37. */ +#define DTM_ERROR_ILLEGAL_CONFIGURATION 0x04 /**< Parameter out of range (legal range is function dependent). */ +#define DTM_ERROR_UNINITIALIZED 0x05 /**< DTM module has not been initialized by the application. */ + +// Note: DTM_PKT_VENDORSPECIFIC, is not a packet type +#define PACKET_TYPE_MAX DTM_PKT_0X55 /**< Highest value allowed as DTM Packet type. */ + +/** @brief BLE DTM event type. */ +typedef uint32_t dtm_event_t; /**< Type for handling DTM event. */ + +/** @brief BLE DTM frequency type. */ +typedef uint32_t dtm_freq_t; /**< Physical channel, valid range: 0..39. */ + +/**@brief BLE DTM packet types. */ +typedef uint32_t dtm_pkt_type_t; /**< Type for holding the requested DTM payload type.*/ + + +/**@brief Function for initializing or re-initializing DTM module + * + * @return DTM_SUCCESS on successful initialization of the DTM module. +*/ +uint32_t dtm_init(void); + + +/**@brief Function for giving control to dtmlib for handling timer and radio events. + * Will return to caller at 625us intervals or whenever another event than radio occurs + * (such as UART input). Function will put MCU to sleep between events. + * + * @return Time counter, incremented every 625 us. + */ +uint32_t dtm_wait(void); + + +/**@brief Function for calling when a complete command has been prepared by the Tester. + * + * @param[in] cmd One of the DTM_CMD values (bits 14:15 in the 16-bit UART format). + * @param[in] freq Phys. channel no - actual frequency = (2402 + freq * 2) MHz (bits 8:13 in + * the 16-bit UART format). + * @param[in] length Payload length, 0..37 (bits 2:7 in the 16-bit UART format). + * @param[in] payload One of the DTM_PKT values (bits 0:1 in the 16-bit UART format). + * + * @return DTM_SUCCESS or one of the DTM_ERROR_ values + */ +uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t payload); + + +/**@brief Function for reading the result of a DTM command + * + * @param[out] p_dtm_event Pointer to buffer for 16 bit event code according to DTM standard. + * + * @return true: new event, false: no event since last call, this event has been read earlier + */ +bool dtm_event_get(dtm_event_t * p_dtm_event); + + +/**@brief Function for configuring the timer to use. + * + * @note Must be called when no DTM test is running. + * + * @param[in] new_timer Index (0..2) of timer to be used by the DTM library + * + * @return true: success, new timer was selected, false: parameter error + */ +bool dtm_set_timer(uint32_t new_timer); + + +/**@brief Function for configuring the transmit power. + * + * @note Must be called when no DTM test is running. + * + * @param[in] new_tx_power New output level, +4..-40, in steps of 4. + * + * @return true: tx power setting changed, false: parameter error + */ +bool dtm_set_txpower(uint32_t new_tx_power); + +#endif // BLE_DTM_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_error_log.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_error_log.h new file mode 100644 index 0000000000..6a4084f534 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_error_log.h @@ -0,0 +1,70 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_error_log_module Error Log Module + * @{ + * @ingroup ble_sdk_lib + * @brief Module for writing error and stack to flash memory. + * + * @details It contains functions for writing an error code, line number, filename/message and + * the stack to the flash during an error, e.g. in the assert handler. + * + */ +#ifndef BLE_ERROR_LOG_H__ +#define BLE_ERROR_LOG_H__ + +#include +#include +#include "ble_flash.h" +#include "nordic_global.h" + +#define ERROR_MESSAGE_LENGTH 128 /**< Length of error message to stored. */ +#define STACK_DUMP_LENGTH 256 /**< Length of stack to be stored at max: 64 entries of 4 bytes each. */ +#define FLASH_PAGE_ERROR_LOG (BLE_FLASH_PAGE_END - 2) /**< Address in flash where stack trace can be stored. */ + +/**@brief Error Log Data structure. + * + * @details The structure contains the error, message/filename, line number as well as the current + * stack, at the time where an error occured. + */ +typedef struct +{ + uint16_t failure; /**< Indication that a major failure has occurred during last execution of the application. */ + uint16_t line_number; /**< Line number indicating at which line the failure occurred. */ + uint32_t err_code; /**< Error code when failure occurred. */ + uint8_t message[ERROR_MESSAGE_LENGTH]; /**< Will just use the first 128 bytes of filename to store for debugging purposes. */ + uint32_t stack_info[STACK_DUMP_LENGTH / 4]; /**< Will contain stack information, can be manually unwinded for debug purposes. */ +} ble_error_log_data_t; + + +/**@brief Function for writing the file name/message, line number, and current program stack + * to flash. + * + * @note This function will force the writing to flash, and disregard any radio communication. + * USE THIS FUNCTION WITH CARE. + * + * @param[in] err_code Error code to be logged. + * @param[in] p_message Message to be written to the flash together with stack dump, usually + * the file name where the error occured. + * @param[in] line_number Line number where the error occured. + * + * @return NRF_SUCCESS on successful writing of the error log. + * + */ +uint32_t ble_error_log_write(uint32_t err_code, const uint8_t * p_message, uint16_t line_number); + + +#endif /* BLE_ERROR_LOG_H__ */ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_flash.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_flash.h new file mode 100644 index 0000000000..9670ec9276 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_flash.h @@ -0,0 +1,143 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_flash_module Flash Manager + * @{ + * @ingroup ble_sdk_lib + * @brief Module for accessing flash memory. + * + * @details It contains functions for reading, writing and erasing one page in flash. + * + * The module uses the first 32 bits of the flash page to write a magic number in order to + * determine if the page has been written or not. + * + * @note Be careful not to use a page number in the SoftDevice area (which currently occupies the + * range 0 to 127), or in your application space! In both cases, this would end up + * with a hard fault. + */ + +#ifndef BLE_FLASH_H__ +#define BLE_FLASH_H__ + +#include +#include +#include +#include "nordic_global.h" + +#define BLE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE) /**< Size of one flash page. */ +#define BLE_FLASH_MAGIC_NUMBER 0x45DE0000 /**< Magic value to identify if flash contains valid data. */ +#define BLE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */ + + +/**@brief Macro for getting the end of the flash available for application. + * + * @details The result flash page number indicates the end boundary of the flash available + * to the application. If a bootloader is used, the end will be the start of the + * bootloader region. Otherwise, the end will be the size of the flash. + */ +#define BLE_FLASH_PAGE_END \ + ((NRF_UICR->BOOTLOADERADDR != BLE_FLASH_EMPTY_MASK) \ + ? (NRF_UICR->BOOTLOADERADDR / BLE_FLASH_PAGE_SIZE) \ + : NRF_FICR->CODESIZE) + +/**@brief Function for erasing the specified flash page, and then writes the given data to this page. + * + * @warning This operation blocks the CPU. DO NOT use while in a connection! + * + * @param[in] page_num Page number to update. + * @param[in] p_in_array Pointer to a RAM area containing the elements to write in flash. + * This area has to be 32 bits aligned. + * @param[in] word_count Number of 32 bits words to write in flash. + * + * @return NRF_SUCCESS on successful flash write, otherwise an error code. + */ +uint32_t ble_flash_page_write(uint8_t page_num, uint32_t * p_in_array, uint8_t word_count); + +/**@brief Function for reading data from flash to RAM. + * + * @param[in] page_num Page number to read. + * @param[out] p_out_array Pointer to a RAM area where the found data will be written. + * This area has to be 32 bits aligned. + * @param[out] p_word_count Number of 32 bits words read. + * + * @return NRF_SUCCESS on successful upload, NRF_ERROR_NOT_FOUND if no valid data has been found + * in flash (first 32 bits not equal to the MAGIC_NUMBER+CRC). + */ +uint32_t ble_flash_page_read(uint8_t page_num, uint32_t * p_out_array, uint8_t * p_word_count); + +/**@brief Function for erasing a flash page. + * + * @note This operation blocks the CPU, so it should not be done while the radio is running! + * + * @param[in] page_num Page number to erase. + * + * @return NRF_SUCCESS on success, an error_code otherwise. + */ +uint32_t ble_flash_page_erase(uint8_t page_num); + +/**@brief Function for writing one word to flash. + * + * @note Flash location to be written must have been erased previously. + * + * @param[in] p_address Pointer to flash location to be written. + * @param[in] value Value to write to flash. + * + * @return NRF_SUCCESS. + */ +uint32_t ble_flash_word_write(uint32_t * p_address, uint32_t value); + +/**@brief Function for writing a data block to flash. + * + * @note Flash locations to be written must have been erased previously. + * + * @param[in] p_address Pointer to start of flash location to be written. + * @param[in] p_in_array Pointer to start of flash block to be written. + * @param[in] word_count Number of words to be written. + * + * @return NRF_SUCCESS. + */ +uint32_t ble_flash_block_write(uint32_t * p_address, uint32_t * p_in_array, uint16_t word_count); + +/**@brief Function for computing pointer to start of specified flash page. + * + * @param[in] page_num Page number. + * @param[out] pp_page_addr Pointer to start of flash page. + * + * @return NRF_SUCCESS. + */ +uint32_t ble_flash_page_addr(uint8_t page_num, uint32_t ** pp_page_addr); + +/**@brief Function for calculating a 16 bit CRC using the CRC-16-CCITT scheme. + * + * @param[in] p_data Pointer to data on which the CRC is to be calulated. + * @param[in] size Number of bytes on which the CRC is to be calulated. + * @param[in] p_crc Initial CRC value (if NULL, a preset value is used as the initial value). + * + * @return Calculated CRC. + */ +uint16_t ble_flash_crc16_compute(uint8_t * p_data, uint16_t size, uint16_t * p_crc); + +/**@brief Function for handling flashing module Radio Notification event. + * + * @note For flash writing to work safely while in a connection or while advertising, this function + * MUST be called from the Radio Notification module's event handler (see + * @ref ble_radio_notification for details). + * + * @param[in] radio_active TRUE if radio is active (or about to become active), FALSE otherwise. + */ +void ble_flash_on_radio_active_evt(bool radio_active); + +#endif // BLE_FLASH_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_racp.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_racp.h new file mode 100644 index 0000000000..9528fcbb5d --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_racp.h @@ -0,0 +1,98 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + */ + +/** @file + * + * @defgroup ble_sdk_lib_racp Record Access Control Point + * @{ + * @ingroup ble_sdk_lib + * @brief Record Access Control Point library. + */ + +#ifndef BLE_RACP_H__ +#define BLE_RACP_H__ + +#include +#include +#include "nordic_global.h" +#include "ble.h" +#include "ble_types.h" +#include "ble.h" + +/**@brief Record Access Control Point opcodes. */ +#define RACP_OPCODE_RESERVED 0 /**< Record Access Control Point opcode - Reserved for future use. */ +#define RACP_OPCODE_REPORT_RECS 1 /**< Record Access Control Point opcode - Report stored records. */ +#define RACP_OPCODE_DELETE_RECS 2 /**< Record Access Control Point opcode - Delete stored records. */ +#define RACP_OPCODE_ABORT_OPERATION 3 /**< Record Access Control Point opcode - Abort operation. */ +#define RACP_OPCODE_REPORT_NUM_RECS 4 /**< Record Access Control Point opcode - Report number of stored records. */ +#define RACP_OPCODE_NUM_RECS_RESPONSE 5 /**< Record Access Control Point opcode - Number of stored records response. */ +#define RACP_OPCODE_RESPONSE_CODE 6 /**< Record Access Control Point opcode - Response code. */ + +/**@brief Record Access Control Point operators. */ +#define RACP_OPERATOR_NULL 0 /**< Record Access Control Point operator - Null. */ +#define RACP_OPERATOR_ALL 1 /**< Record Access Control Point operator - All records. */ +#define RACP_OPERATOR_LESS_OR_EQUAL 2 /**< Record Access Control Point operator - Less than or equal to. */ +#define RACP_OPERATOR_GREATER_OR_EQUAL 3 /**< Record Access Control Point operator - Greater than or equal to. */ +#define RACP_OPERATOR_RANGE 4 /**< Record Access Control Point operator - Within range of (inclusive). */ +#define RACP_OPERATOR_FIRST 5 /**< Record Access Control Point operator - First record (i.e. oldest record). */ +#define RACP_OPERATOR_LAST 6 /**< Record Access Control Point operator - Last record (i.e. most recent record). */ +#define RACP_OPERATOR_RFU_START 7 /**< Record Access Control Point operator - Start of Reserved for Future Use area. */ + +/**@brief Record Access Control Point response codes. */ +#define RACP_RESPONSE_RESERVED 0 /**< Record Access Control Point response code - Reserved for future use. */ +#define RACP_RESPONSE_SUCCESS 1 /**< Record Access Control Point response code - Successful operation. */ +#define RACP_RESPONSE_OPCODE_UNSUPPORTED 2 /**< Record Access Control Point response code - Unsupported op code received. */ +#define RACP_RESPONSE_INVALID_OPERATOR 3 /**< Record Access Control Point response code - Operator not valid for service. */ +#define RACP_RESPONSE_OPERATOR_UNSUPPORTED 4 /**< Record Access Control Point response code - Unsupported operator. */ +#define RACP_RESPONSE_INVALID_OPERAND 5 /**< Record Access Control Point response code - Operand not valid for service. */ +#define RACP_RESPONSE_NO_RECORDS_FOUND 6 /**< Record Access Control Point response code - No matching records found. */ +#define RACP_RESPONSE_ABORT_FAILED 7 /**< Record Access Control Point response code - Abort could not be completed. */ +#define RACP_RESPONSE_PROCEDURE_NOT_DONE 8 /**< Record Access Control Point response code - Procedure could not be completed. */ +#define RACP_RESPONSE_OPERAND_UNSUPPORTED 9 /**< Record Access Control Point response code - Unsupported operand. */ + +/**@brief Record Access Control Point value structure. */ +typedef struct +{ + uint8_t opcode; /**< Op Code. */ + uint8_t operator; /**< Operator. */ + uint8_t operand_len; /**< Length of the operand. */ + uint8_t * p_operand; /**< Pointer to the operand. */ +} ble_racp_value_t; + +/**@brief Function for decoding a Record Access Control Point write. + * + * @details This call decodes a write to the Record Access Control Point. + * + * @param[in] data_len Length of data in received write. + * @param[in] p_data Pointer to received data. + * @param[out] p_racp_val Pointer to decoded Record Access Control Point write. + * @note This does not do a data copy. It assumes the data pointed to by + * p_data is persistant until no longer needed. + */ +void ble_racp_decode(uint8_t data_len, uint8_t * p_data, ble_racp_value_t * p_racp_val); + +/**@brief Function for encoding a Record Access Control Point response. + * + * @details This call encodes a response from the Record Access Control Point response. + * + * @param[in] p_racp_val Pointer to Record Access Control Point to encode. + * @param[out] p_data Pointer to where encoded data is written. + * NOTE! It is calling routines respsonsibility to make sure. + * + * @return Length of encoded data. + */ +uint8_t ble_racp_encode(const ble_racp_value_t * p_racp_val, uint8_t * p_data); + +#endif // BLE_RACP_H__ + +/** @} */ + +/** @endcond */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_radio_notification.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_radio_notification.h new file mode 100644 index 0000000000..35e781d43c --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_radio_notification.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + */ + +/** @file + * + * @defgroup ble_radio_notification Radio Notification Event Handler + * @{ + * @ingroup ble_sdk_lib + * @brief Module for propagating Radio Notification events to the application. + */ + +#ifndef BLE_RADIO_NOTIFICATION_H__ +#define BLE_RADIO_NOTIFICATION_H__ + +#include +#include +#include "nordic_global.h" +#include "nrf_soc.h" + +/**@brief Application radio notification event handler type. */ +typedef void (*ble_radio_notification_evt_handler_t) (bool radio_active); + +/**@brief Function for initializing the Radio Notification module. + * + * @param[in] irq_priority Interrupt priority for the Radio Notification interrupt handler. + * @param[in] distance The time from an Active event until the radio is activated. + * @param[in] evt_handler Handler to be executed when a radio notification event has been + * received. + * + * @return NRF_SUCCESS on successful initialization, otherwise an error code. + */ +uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority, + nrf_radio_notification_distance_t distance, + ble_radio_notification_evt_handler_t evt_handler); + +#endif // BLE_RADIO_NOTIFICATION_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_sensorsim.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_sensorsim.h new file mode 100644 index 0000000000..02fb08e594 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_sensorsim.h @@ -0,0 +1,66 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_sdk_lib_sensorsim Sensor Data Simulator + * @{ + * @ingroup ble_sdk_lib + * @brief Functions for simulating sensor data. + * + * @details Currently only a triangular waveform simulator is implemented. + */ + +#ifndef BLE_SENSORSIM_H__ +#define BLE_SENSORSIM_H__ + +#include +#include +#include "nordic_global.h" + +/**@brief Triangular waveform sensor simulator configuration. */ +typedef struct +{ + uint32_t min; /**< Minimum simulated value. */ + uint32_t max; /**< Maximum simulated value. */ + uint32_t incr; /**< Increment between each measurement. */ + bool start_at_max; /**< TRUE is measurement is to start at the maximum value, FALSE if it is to start at the minimum. */ +} ble_sensorsim_cfg_t; + +/**@brief Triangular waveform sensor simulator state. */ +typedef struct +{ + uint32_t current_val; /**< Current sensor value. */ + bool is_increasing; /**< TRUE if the simulator is in increasing state, FALSE otherwise. */ +} ble_sensorsim_state_t; + +/**@brief Function for initializing a triangular waveform sensor simulator. + * + * @param[out] p_state Current state of simulator. + * @param[in] p_cfg Simulator configuration. + */ +void ble_sensorsim_init(ble_sensorsim_state_t * p_state, + const ble_sensorsim_cfg_t * p_cfg); + +/**@brief Function for generating a simulated sensor measurement using a triangular waveform generator. + * + * @param[in,out] p_state Current state of simulator. + * @param[in] p_cfg Simulator configuration. + * + * @return Simulator output. + */ +uint32_t ble_sensorsim_measure(ble_sensorsim_state_t * p_state, + const ble_sensorsim_cfg_t * p_cfg); + +#endif // BLE_SENSORSIM_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_services/ble_srv_common.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_services/ble_srv_common.h new file mode 100644 index 0000000000..f27d48021c --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/ble_services/ble_srv_common.h @@ -0,0 +1,235 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_sdk_srv_common 'Common service definitions' + * @{ + * @ingroup ble_sdk_srv + * @brief Constants, type definitions and functions that are common to all services. + */ + +#ifndef BLE_SRV_COMMON_H__ +#define BLE_SRV_COMMON_H__ + +#include +#include +#include "nordic_global.h" +#include "ble_types.h" +#include "app_util.h" +#include "ble_gap.h" +#include "ble_gatt.h" + +/** @defgroup UUID_SERVICES Service UUID definitions + * @{ */ +#define BLE_UUID_ALERT_NOTIFICATION_SERVICE 0x1811 /**< Alert Notification service UUID. */ +#define BLE_UUID_BATTERY_SERVICE 0x180F /**< Battery service UUID. */ +#define BLE_UUID_BLOOD_PRESSURE_SERVICE 0x1810 /**< Blood Pressure service UUID. */ +#define BLE_UUID_CURRENT_TIME_SERVICE 0x1805 /**< Current Time service UUID. */ +#define BLE_UUID_CYCLING_SPEED_AND_CADENCE 0x1816 /**< Cycling Speed and Cadence service UUID. */ +#define BLE_UUID_DEVICE_INFORMATION_SERVICE 0x180A /**< Device Information service UUID. */ +#define BLE_UUID_GLUCOSE_SERVICE 0x1808 /**< Glucose service UUID. */ +#define BLE_UUID_HEALTH_THERMOMETER_SERVICE 0x1809 /**< Health Thermometer service UUID. */ +#define BLE_UUID_HEART_RATE_SERVICE 0x180D /**< Heart Rate service UUID. */ +#define BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE 0x1812 /**< Human Interface Device service UUID. */ +#define BLE_UUID_IMMEDIATE_ALERT_SERVICE 0x1802 /**< Immediate Alert service UUID. */ +#define BLE_UUID_LINK_LOSS_SERVICE 0x1803 /**< Link Loss service UUID. */ +#define BLE_UUID_NEXT_DST_CHANGE_SERVICE 0x1807 /**< Next Dst Change service UUID. */ +#define BLE_UUID_PHONE_ALERT_STATUS_SERVICE 0x180E /**< Phone Alert Status service UUID. */ +#define BLE_UUID_REFERENCE_TIME_UPDATE_SERVICE 0x1806 /**< Reference Time Update service UUID. */ +#define BLE_UUID_RUNNING_SPEED_AND_CADENCE 0x1814 /**< Running Speed and Cadence service UUID. */ +#define BLE_UUID_SCAN_PARAMETERS_SERVICE 0x1813 /**< Scan Parameters service UUID. */ +#define BLE_UUID_TX_POWER_SERVICE 0x1804 /**< TX Power service UUID. */ +/** @} */ + +/** @defgroup UUID_CHARACTERISTICS Characteristic UUID definitions + * @{ */ +#define BLE_UUID_BATTERY_LEVEL_STATE_CHAR 0x2A1B /**< Battery Level State characteristic UUID. */ +#define BLE_UUID_BATTERY_POWER_STATE_CHAR 0x2A1A /**< Battery Power State characteristic UUID. */ +#define BLE_UUID_REMOVABLE_CHAR 0x2A3A /**< Removable characteristic UUID. */ +#define BLE_UUID_SERVICE_REQUIRED_CHAR 0x2A3B /**< Service Required characteristic UUID. */ +#define BLE_UUID_ALERT_CATEGORY_ID_CHAR 0x2A43 /**< Alert Category Id characteristic UUID. */ +#define BLE_UUID_ALERT_CATEGORY_ID_BIT_MASK_CHAR 0x2A42 /**< Alert Category Id Bit Mask characteristic UUID. */ +#define BLE_UUID_ALERT_LEVEL_CHAR 0x2A06 /**< Alert Level characteristic UUID. */ +#define BLE_UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR 0x2A44 /**< Alert Notification Control Point characteristic UUID. */ +#define BLE_UUID_ALERT_STATUS_CHAR 0x2A3F /**< Alert Status characteristic UUID. */ +#define BLE_UUID_BATTERY_LEVEL_CHAR 0x2A19 /**< Battery Level characteristic UUID. */ +#define BLE_UUID_BLOOD_PRESSURE_FEATURE_CHAR 0x2A49 /**< Blood Pressure Feature characteristic UUID. */ +#define BLE_UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR 0x2A35 /**< Blood Pressure Measurement characteristic UUID. */ +#define BLE_UUID_BODY_SENSOR_LOCATION_CHAR 0x2A38 /**< Body Sensor Location characteristic UUID. */ +#define BLE_UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR 0x2A22 /**< Boot Keyboard Input Report characteristic UUID. */ +#define BLE_UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR 0x2A32 /**< Boot Keyboard Output Report characteristic UUID. */ +#define BLE_UUID_BOOT_MOUSE_INPUT_REPORT_CHAR 0x2A33 /**< Boot Mouse Input Report characteristic UUID. */ +#define BLE_UUID_CURRENT_TIME_CHAR 0x2A2B /**< Current Time characteristic UUID. */ +#define BLE_UUID_DATE_TIME_CHAR 0x2A08 /**< Date Time characteristic UUID. */ +#define BLE_UUID_DAY_DATE_TIME_CHAR 0x2A0A /**< Day Date Time characteristic UUID. */ +#define BLE_UUID_DAY_OF_WEEK_CHAR 0x2A09 /**< Day Of Week characteristic UUID. */ +#define BLE_UUID_DST_OFFSET_CHAR 0x2A0D /**< Dst Offset characteristic UUID. */ +#define BLE_UUID_EXACT_TIME_256_CHAR 0x2A0C /**< Exact Time 256 characteristic UUID. */ +#define BLE_UUID_FIRMWARE_REVISION_STRING_CHAR 0x2A26 /**< Firmware Revision String characteristic UUID. */ +#define BLE_UUID_GLUCOSE_FEATURE_CHAR 0x2A51 /**< Glucose Feature characteristic UUID. */ +#define BLE_UUID_GLUCOSE_MEASUREMENT_CHAR 0x2A18 /**< Glucose Measurement characteristic UUID. */ +#define BLE_UUID_GLUCOSE_MEASUREMENT_CONTEXT_CHAR 0x2A34 /**< Glucose Measurement Context characteristic UUID. */ +#define BLE_UUID_HARDWARE_REVISION_STRING_CHAR 0x2A27 /**< Hardware Revision String characteristic UUID. */ +#define BLE_UUID_HEART_RATE_CONTROL_POINT_CHAR 0x2A39 /**< Heart Rate Control Point characteristic UUID. */ +#define BLE_UUID_HEART_RATE_MEASUREMENT_CHAR 0x2A37 /**< Heart Rate Measurement characteristic UUID. */ +#define BLE_UUID_HID_CONTROL_POINT_CHAR 0x2A4C /**< Hid Control Point characteristic UUID. */ +#define BLE_UUID_HID_INFORMATION_CHAR 0x2A4A /**< Hid Information characteristic UUID. */ +#define BLE_UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR 0x2A2A /**< IEEE Regulatory Certification Data List characteristic UUID. */ +#define BLE_UUID_INTERMEDIATE_CUFF_PRESSURE_CHAR 0x2A36 /**< Intermediate Cuff Pressure characteristic UUID. */ +#define BLE_UUID_INTERMEDIATE_TEMPERATURE_CHAR 0x2A1E /**< Intermediate Temperature characteristic UUID. */ +#define BLE_UUID_LOCAL_TIME_INFORMATION_CHAR 0x2A0F /**< Local Time Information characteristic UUID. */ +#define BLE_UUID_MANUFACTURER_NAME_STRING_CHAR 0x2A29 /**< Manufacturer Name String characteristic UUID. */ +#define BLE_UUID_MEASUREMENT_INTERVAL_CHAR 0x2A21 /**< Measurement Interval characteristic UUID. */ +#define BLE_UUID_MODEL_NUMBER_STRING_CHAR 0x2A24 /**< Model Number String characteristic UUID. */ +#define BLE_UUID_UNREAD_ALERT_CHAR 0x2A45 /**< Unread Alert characteristic UUID. */ +#define BLE_UUID_NEW_ALERT_CHAR 0x2A46 /**< New Alert characteristic UUID. */ +#define BLE_UUID_PNP_ID_CHAR 0x2A50 /**< PNP Id characteristic UUID. */ +#define BLE_UUID_PROTOCOL_MODE_CHAR 0x2A4E /**< Protocol Mode characteristic UUID. */ +#define BLE_UUID_RECORD_ACCESS_CONTROL_POINT_CHAR 0x2A52 /**< Record Access Control Point characteristic UUID. */ +#define BLE_UUID_REFERENCE_TIME_INFORMATION_CHAR 0x2A14 /**< Reference Time Information characteristic UUID. */ +#define BLE_UUID_REPORT_CHAR 0x2A4D /**< Report characteristic UUID. */ +#define BLE_UUID_REPORT_MAP_CHAR 0x2A4B /**< Report Map characteristic UUID. */ +#define BLE_UUID_RINGER_CONTROL_POINT_CHAR 0x2A40 /**< Ringer Control Point characteristic UUID. */ +#define BLE_UUID_RINGER_SETTING_CHAR 0x2A41 /**< Ringer Setting characteristic UUID. */ +#define BLE_UUID_SCAN_INTERVAL_WINDOW_CHAR 0x2A4F /**< Scan Interval Window characteristic UUID. */ +#define BLE_UUID_SCAN_REFRESH_CHAR 0x2A31 /**< Scan Refresh characteristic UUID. */ +#define BLE_UUID_SERIAL_NUMBER_STRING_CHAR 0x2A25 /**< Serial Number String characteristic UUID. */ +#define BLE_UUID_SOFTWARE_REVISION_STRING_CHAR 0x2A28 /**< Software Revision String characteristic UUID. */ +#define BLE_UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR 0x2A47 /**< Supported New Alert Category characteristic UUID. */ +#define BLE_UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR 0x2A48 /**< Supported Unread Alert Category characteristic UUID. */ +#define BLE_UUID_SYSTEM_ID_CHAR 0x2A23 /**< System Id characteristic UUID. */ +#define BLE_UUID_TEMPERATURE_MEASUREMENT_CHAR 0x2A1C /**< Temperature Measurement characteristic UUID. */ +#define BLE_UUID_TEMPERATURE_TYPE_CHAR 0x2A1D /**< Temperature Type characteristic UUID. */ +#define BLE_UUID_TIME_ACCURACY_CHAR 0x2A12 /**< Time Accuracy characteristic UUID. */ +#define BLE_UUID_TIME_SOURCE_CHAR 0x2A13 /**< Time Source characteristic UUID. */ +#define BLE_UUID_TIME_UPDATE_CONTROL_POINT_CHAR 0x2A16 /**< Time Update Control Point characteristic UUID. */ +#define BLE_UUID_TIME_UPDATE_STATE_CHAR 0x2A17 /**< Time Update State characteristic UUID. */ +#define BLE_UUID_TIME_WITH_DST_CHAR 0x2A11 /**< Time With Dst characteristic UUID. */ +#define BLE_UUID_TIME_ZONE_CHAR 0x2A0E /**< Time Zone characteristic UUID. */ +#define BLE_UUID_TX_POWER_LEVEL_CHAR 0x2A07 /**< TX Power Level characteristic UUID. */ +#define BLE_UUID_CSC_FEATURE_CHAR 0x2A5C /**< Cycling Speed and Cadence Feature characteristic UUID. */ +#define BLE_UUID_CSC_MEASUREMENT_CHAR 0x2A5B /**< Cycling Speed and Cadence Measurement characteristic UUID. */ +#define BLE_UUID_RSC_FEATURE_CHAR 0x2A54 /**< Running Speed and Cadence Feature characteristic UUID. */ +#define BLE_UUID_SC_CTRLPT_CHAR 0x2A55 /**< Speed and Cadence Control Point UUID. */ +#define BLE_UUID_RSC_MEASUREMENT_CHAR 0x2A53 /**< Running Speed and Cadence Measurement characteristic UUID. */ +#define BLE_UUID_SENSOR_LOCATION_CHAR 0x2A5D /**< Sensor Location characteristic UUID. */ +/** @} */ + +/** @defgroup UUID_CHARACTERISTICS descriptors UUID definitions + * @{ */ +#define BLE_UUID_EXTERNAL_REPORT_REF_DESCR 0x2907 /**< External Report Reference descriptor UUID. */ +#define BLE_UUID_REPORT_REF_DESCR 0x2908 /**< Report Reference descriptor UUID. */ +/** @} */ + +/** @defgroup ALERT_LEVEL_VALUES Definitions for the Alert Level characteristic values + * @{ */ +#define BLE_CHAR_ALERT_LEVEL_NO_ALERT 0x00 /**< No Alert. */ +#define BLE_CHAR_ALERT_LEVEL_MILD_ALERT 0x01 /**< Mild Alert. */ +#define BLE_CHAR_ALERT_LEVEL_HIGH_ALERT 0x02 /**< High Alert. */ +/** @} */ + +#define BLE_SRV_ENCODED_REPORT_REF_LEN 2 /**< The length of an encoded Report Reference Descriptor. */ +#define BLE_CCCD_VALUE_LEN 2 /**< The length of a CCCD value. */ + +/**@brief Type definition for error handler function which will be called in case of an error in + * a service or a service library module. */ +typedef void (*ble_srv_error_handler_t)(uint32_t nrf_error); + +/**@brief Value of a Report Reference descriptor. + * + * @details This is mapping information which maps the parent characteristic to the Report ID(s) and + * Report Type(s) defined within a Report Map characteristic. + */ +typedef struct +{ + uint8_t report_id; /**< Non-zero value if these is more than one instance of the same Report Type */ + uint8_t report_type; /**< Type of Report characteristic (see @ref BLE_SRV_HIDS_REPORT_TYPE) */ +} ble_srv_report_ref_t; + +/**@brief UTF-8 string data type. + * + * @note The type can only hold a pointer to the string data (i.e. not the actual data). + */ +typedef struct +{ + uint16_t length; /**< String length. */ + uint8_t * p_str; /**< String data. */ +} ble_srv_utf8_str_t; + +/**@brief Security settings structure. + * @details This structure contains the security options needed during initialization of the + * service. + */ +typedef struct +{ + ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */ + ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ +} ble_srv_security_mode_t; + +/**@brief Security settings structure. + * @details This structure contains the security options needed during initialization of the + * service. It can be used when the charecteristics contains cccd. + */ +typedef struct +{ + ble_gap_conn_sec_mode_t cccd_write_perm; + ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */ + ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ +} ble_srv_cccd_security_mode_t; + +/**@brief Function for decoding a CCCD value, and then testing if notification is + * enabled. + * + * @param[in] p_encoded_data Buffer where the encoded CCCD is stored. + * + * @return TRUE if notification is enabled, FALSE otherwise. + */ +static __INLINE bool ble_srv_is_notification_enabled(uint8_t * p_encoded_data) +{ + uint16_t cccd_value = uint16_decode(p_encoded_data); + return ((cccd_value & BLE_GATT_HVX_NOTIFICATION) != 0); +} + +/**@brief Function for decoding a CCCD value, and then testing if indication is + * enabled. + * + * @param[in] p_encoded_data Buffer where the encoded CCCD is stored. + * + * @return TRUE if indication is enabled, FALSE otherwise. + */ +static __INLINE bool ble_srv_is_indication_enabled(uint8_t * p_encoded_data) +{ + uint16_t cccd_value = uint16_decode(p_encoded_data); + return ((cccd_value & BLE_GATT_HVX_INDICATION) != 0); +} + +/**@brief Function for encoding a Report Reference Descriptor. + * + * @param[in] p_encoded_buffer The buffer of the encoded data. + * @param[in] p_report_ref Report Reference value to be encoded. + * + * @return Length of the encoded data. + */ +uint8_t ble_srv_report_ref_encode(uint8_t * p_encoded_buffer, + const ble_srv_report_ref_t * p_report_ref); + +/**@brief Function for making UTF-8 structure refer to an ASCII string. + * + * @param[out] p_utf8 UTF-8 structure to be set. + * @param[in] p_ascii ASCII string to be referred to. + */ +void ble_srv_ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, char * p_ascii); + +#endif // BLE_SRV_COMMON_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder.h new file mode 100644 index 0000000000..8a744bea8a --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder.h @@ -0,0 +1,81 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_cmd_decoder Command Decoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Decoder for serialized commands from Application Chip. + * + * @details This file contains declaration of common functions used for sending responses back to + * Application Chip after the command is processed, and function for processing commands + * received by the transport layer. + */ + +#ifndef BLE_RPC_CMD_DECODER_H__ +#define BLE_RPC_CMD_DECODER_H__ + +#include + +#define RPC_DECODER_LENGTH_CHECK(LEN, INDEX, CMD) if ( INDEX > LEN) \ + return ble_rpc_cmd_resp_send(CMD, NRF_ERROR_INVALID_LENGTH); + +/**@brief Function for sending a Command Response packet to the Application Chip through the transport + * layer. + * + * @param[in] op_code The op code of the command for which the Command Response is sent. + * @param[in] status The status field to be encoded into the Command Response. + * + * @retval NRF_SUCCESS On successful write of Command Response, otherwise an error code. + * If the transport layer returns an error code while sending + * the Command Response, the same error code will be returned by this + * function (see @ref hci_transport_pkt_write for the list of + * error codes). + */ +uint32_t ble_rpc_cmd_resp_send(uint8_t op_code, uint32_t status); + +/**@brief Function for sending a command response with additional data to the Application Chip through + * the transport layer. + * + * @param[in] op_code The op code of the command for which the Command Response is sent. + * @param[in] status The status field to be encoded into the Command Response. + * @param[in] p_data The data to be sent along with the status. + * @param[in] data_len The length of the additional data. + * + * @retval NRF_SUCCESS On successful write of Command Response, otherwise an error code. + * If the transport layer returns an error code while sending + * the Command Response, the same error code will be returned by this + * function (see @ref hci_transport_pkt_write for the list of + * error codes). + */ +uint32_t ble_rpc_cmd_resp_data_send(uint8_t op_code, + uint8_t status, + const uint8_t * const p_data, + uint16_t data_len); + +/**@brief Function for scheduling an RPC command event to be processed in main-thread. + * + * @details The function will read the arrived packet from the transport layer + * which is passed for decoding by the rpc_cmd_decoder module. + * + * @param[in] p_event_data Event data. This will be NULL as rpc_evt_schedule + * does not set any data. + * @param[in] event_size Event data size. This will be 0 as rpc_evt_schedule + * does not set any data. + */ +void ble_rpc_cmd_handle(void * p_event_data, uint16_t event_size); + +#endif // BLE_RPC_CMD_DECODER_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gap.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gap.h new file mode 100644 index 0000000000..41edb3776d --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gap.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_cmd_decoder_gap GAP Command Decoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Decoder for serialized GAP commands from Application Chip. + * + * @details This file contains the declaration of the function that decodes the serialized GAP + * commands from Application Chip and calls the appropriate BLE stack API. + */ + +#ifndef BLE_RPC_CMD_DECODER_GAP_H__ +#define BLE_RPC_CMD_DECODER_GAP_H__ + +#include + +/**@brief Function for processing the encoded GAP command from Application Chip. + * + * @details This function will decode the encoded command and call the appropriate BLE Stack + * API. It will then create a Command Response packet with the return value from the + * stack API encoded in it and will send it to the transport layer for transmission to + * the application controller chip. + + * @param[in] p_command The encoded command. + * @param[in] op_code Operation code of the command. + * @param[in] command_len Length of the encoded command. + * + * @retval NRF_SUCCESS If the decoding of the command was successful, the soft device API + * was called, and the command response was sent to peer, otherwise an + * error code. + * If the transport layer returns an error code while sending + * the Command Response, the same error code will be returned by this + * function (see @ref hci_transport_pkt_write for the list of + * error codes). + */ +uint32_t ble_rpc_cmd_gap_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len); + +#endif // BLE_RPC_CMD_DECODER_GAP_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gatts.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gatts.h new file mode 100644 index 0000000000..048cf7a1fd --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_decoder_gatts.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_cmd_decoder_gatts GATTS Command Decoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Decoder for serialized GATTS commands from Application Chip. + * + * @details This file contains the declaration of the function that decodes the serialized GATTS + * commands from Application Chip and calls the appropriate BLE stack API. + */ + +#ifndef BLE_RPC_CMD_DECODER_GATTS_H__ +#define BLE_RPC_CMD_DECODER_GATTS_H__ + +#include + +/**@brief Function for processing the encoded GATTS command from application chip. + * + * @details This function will decode the encoded command and call the appropriate BLE Stack + * API. It will then create a Command Response packet with the return value from the + * stack API encoded in it and will send it to the transport layer for transmission to + * the application controller chip. + + * @param[in] p_command The encoded command. + * @param[in] op_code Operation code of the command. + * @param[in] command_len Length of the encoded command. + * + * @retval NRF_SUCCESS If the decoding of the command was successful, the soft device API + * was called, and the command response was sent to peer, otherwise an + * error code. + * If the transport layer returns an error code while sending + * the Command Response, the same error code will be returned by this + * function (see @ref hci_transport_pkt_write for the list of + * error codes). + */ +uint32_t ble_rpc_cmd_gatts_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len); + +#endif // BLE_RPC_CMD_DECODER_GATTS_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_encoder.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_encoder.h new file mode 100644 index 0000000000..633589e267 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_cmd_encoder.h @@ -0,0 +1,70 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_cmd_encoder Command Encoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Encoder for serialized commands from Application Chip. + * + * @details This file contains the declaration of the functions that encode serialized commands + * from Application Chip. + */ + +#ifndef BLE_RPC_CMD_ENCODER_H__ +#define BLE_RPC_CMD_ENCODER_H__ + +#include +#include "ble_rpc_defines.h" + +/**@brief Command response type. */ +typedef struct +{ + uint8_t op_code; /**< Operation code for which this response applies. */ + uint32_t err_code; /**< Error code received for this response applies. */ +} cmd_response_t; + +/**@brief Function for initializing the BLE S110 RPC Command Encoder module. + * + * @details This function uses the HCI Transport module, \ref hci_transport and executes + * \ref hci_transport_tx_done_register and \ref hci_transport_tx_alloc . All errors + * returned by those functions are passed on by this function. + * + * @retval NRF_SUCCESS Upon success + * @return Errors from \ref hci_transport and \ref hci_transport_tx_alloc . + */ +uint32_t ble_rpc_cmd_encoder_init(void); + +/**@brief Function for blocking in a loop, using WFE to allow low power mode, while awaiting a + * response from the connectivity chip. + * + * @param[in] op_code The Operation Code for which a response message is expected. + * + * @return The decoded error code received from the connectivity chip. + */ +uint32_t ble_rpc_cmd_resp_wait(uint8_t op_code); + +/**@brief Function for handling the command response packet. + * + * @details This function will be called when a command response is received in the transport + * layer. The response is decoded and returned to the waiting caller. + * + * @param[in] p_packet The packet from the transport layer. + * @param[in] packet_length The length of the packet. + */ +void ble_rpc_cmd_rsp_pkt_received(uint8_t * p_packet, uint16_t packet_length); + +#endif // BLE_RPC_CMD_ENCODER_H__ + +/**@} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_defines.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_defines.h new file mode 100644 index 0000000000..9e4eac1e58 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_defines.h @@ -0,0 +1,55 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup rpc_cmd_defines Defines related to serialized BLE commands. + * @{ + * @ingroup ble_sdk_lib + * + * @brief Defines for serialized BLE commands. + * + */ + +#ifndef BLE_RPC_DEFINES_H__ +#define BLE_RPC_DEFINES_H__ + +#define RPC_CMD_OP_CODE_POS 0 /**< Position of the Op Code in the command buffer.*/ +#define RPC_CMD_DATA_POS 1 /**< Position of the data in the command buffer.*/ + +#define RPC_CMD_RESP_PKT_TYPE_POS 0 /**< Position of Packet type in the command response buffer.*/ +#define RPC_CMD_RESP_OP_CODE_POS 1 /**< Position of the Op Code in the command response buffer.*/ +#define RPC_CMD_RESP_STATUS_POS 2 /**< Position of the status field in the command response buffer.*/ + +#define RPC_BLE_FIELD_LEN 1 /**< Optional field length size in bytes. */ +#define RPC_BLE_FIELD_PRESENT 0x01 /**< Value to indicate that an optional field is encoded in the serialized packet, e.g. white list. */ +#define RPC_BLE_FIELD_NOT_PRESENT 0x00 /**< Value to indicate that an optional field is not encoded in the serialized packet. */ + +#define RPC_ERR_CODE_SIZE 4 /**< BLE API err_code size in bytes. */ +#define BLE_PKT_TYPE_SIZE 1 /**< Packet type (@ref ble_rpc_pkt_type_t) field size in bytes. */ +#define BLE_OP_CODE_SIZE 1 /**< Operation code field size in bytes. */ + +#define RPC_BLE_CMD_RESP_PKT_MIN_SIZE 6 /**< Minimum length of a command response. */ +#define RPC_BLE_PKT_MAX_SIZE 596 /**< Maximum size for a BLE packet on the HCI Transport layer. This value is the hci_mem_pool buffer size minus the HCI Transport size. @note This value must be aligned with TX_BUF_SIZE in hci_mem_pool_internal.h. */ + +/**@brief The types of packets. */ +typedef enum +{ + BLE_RPC_PKT_CMD, /**< Command packet type. */ + BLE_RPC_PKT_RESP, /**< Command Response packet type. */ + BLE_RPC_PKT_EVT, /**< Event packet type. */ + BLE_RPC_PKT_TYPE_MAX /**< Upper bound. */ +} ble_rpc_pkt_type_t; + +#endif // BLE_RPC_DEFINES_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder.h new file mode 100644 index 0000000000..2091af72de --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_evt_decoder Event Decoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Decoder for serialized events from nRF51822. + * + * @details This file contains the declaration of the function that initializes the event decoder + * module and processes received events. + */ + +#ifndef BLE_RPC_EVT_DECODER_H__ +#define BLE_RPC_EVT_DECODER_H__ + +#include + +#ifndef SVCALL_AS_NORMAL_FUNCTION +#error "The compiler define SVCALL_AS_NORMAL_FUNCTION is not defined." +#endif + + +/**@brief Function for pushing an encoded packet in the event decoder. + * + * @warning This function is not reentrant safe and should always be called from the same interrupt + * context. + * + * @param[in] p_event_packet Pointer to the encoded event received. + * @param[in] event_packet_length Length of received packet. + * + * @retval NRF_SUCCESS Upon success. + * @retval NRF_ERROR_NO_MEM Upon receive queue full. + */ +uint32_t ble_rpc_event_pkt_received(uint8_t * p_event_packet, uint16_t event_packet_length); + +#endif // BLE_RPC_EVT_DECODER_H__ + +/** @} **/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gap.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gap.h new file mode 100644 index 0000000000..2879fd6d5b --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gap.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_evt_decoder_gap GAP Event Decoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Decoder for serialized GAP events from nRF51822. + * + * @details This file contains declarations of functions used for decoding GAP event packets + * received from the Connectivity Chip. + * + */ + +#ifndef BLE_RPC_EVENT_DECODER_GAP_H__ +#define BLE_RPC_EVENT_DECODER_GAP_H__ + +#include +#include "ble.h" + +/** @brief Function for decoding the length of a BLE GAP event. + * + * @param[in] event_id Event Id for the event to length decode. + * @param[out] p_event_length The pointer for storing the decoded event length. + */ +void ble_rpc_gap_evt_length_decode(uint8_t event_id, uint16_t * p_event_length); + +/** @brief Function for decoding a BLE GAP event. + * + * @param[out] p_ble_evt The pointer for storing the decoded event. + * @param[in] p_packet The pointer to the encoded event. + */ +void ble_rpc_gap_evt_packet_decode(ble_evt_t * p_ble_evt, + uint8_t const * const p_packet); + +#endif // BLE_RPC_EVENT_DECODER_GAP_H__ + +/** @} **/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gatts.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gatts.h new file mode 100644 index 0000000000..dd2554c984 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_decoder_gatts.h @@ -0,0 +1,55 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_evt_decoder_gatts GATTS Event Decoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Decoder for serialized GATT Server events from nRF51822. + * + * @details This file contains declarations of functions used for decoding GATTS event packets + * received from the Connectivity Chip. + * + */ + +#ifndef BLE_RPC_EVENT_DECODER_GATTS_H__ +#define BLE_RPC_EVENT_DECODER_GATTS_H__ + +#include +#include "ble.h" +#include "ble_gatts.h" + +/** @brief Function for decoding the length of a BLE GATTS event. The decoded BLE GATTS event + * length will be returned in p_event_length. + * + * @param[in] event_id Event Id of the event, whose length is to be decoded. + * @param[out] p_event_length The pointer for storing the decoded event length. + * @param[in] p_packet The pointer to the encoded event. + */ +void ble_rpc_gatts_evt_length_decode(uint8_t event_id, + uint16_t * p_event_length, + uint8_t const * const p_packet); + +/** @brief Function for decoding a BLE GATTS event. The decoded BLE GATTS event will be returned in + * the memory pointed to by p_ble_evt. + * + * @param[out] p_ble_evt The pointer for storing the decoded event. + * @param[in] p_packet The pointer to the encoded event. + */ +void ble_rpc_gatts_evt_packet_decode(ble_evt_t * p_ble_evt, + uint8_t const * const p_packet); + +#endif // BLE_RPC_EVENT_DECODER_GATTS_H__ + +/** @} **/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder.h new file mode 100644 index 0000000000..7095ff88c4 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder.h @@ -0,0 +1,38 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_event_encoder Events Encoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Event encoder for S110 SoftDevice serialization. + * + * @details This module provides a function for serializing S110 SoftDevice events. + * + */ +#ifndef BLE_RPC_EVENT_ENCODER_H__ +#define BLE_RPC_EVENT_ENCODER_H__ + +#include "ble.h" + +/**@brief Function for encoding a @ref ble_evt_t. The function will pass the serialized byte stream to the + * transport layer after encoding. + * + * @param[in] p_ble_evt S110 SoftDevice event to serialize. + */ +void ble_rpc_event_handle(ble_evt_t * p_ble_evt); + +#endif // BLE_RPC_EVENT_ENCODER_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gap.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gap.h new file mode 100644 index 0000000000..ab183480c4 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gap.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_event_encoder_gap GAP Event Encoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Event encoder for S110 SoftDevice serialization. + * + * @details This module provides functions for serializing S110 SoftDevice events. + * + */ +#ifndef BLE_RPC_EVENT_ENCODER_GAP_H__ +#define BLE_RPC_EVENT_ENCODER_GAP_H__ + +#include +#include + +/**@brief Function for encoding a @ref ble_evt_t GAP event. + * + * @param[in] p_ble_evt S110 SoftDevice event to serialize. + * @param[out] p_buffer Pointer to a buffer for the encoded event. + * + * @return Number of bytes encoded. + */ +uint32_t ble_rpc_evt_gap_encode(ble_evt_t * p_ble_evt, uint8_t * p_buffer); + +#endif // BLE_RPC_EVENT_ENCODER_GAP_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gatts.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gatts.h new file mode 100644 index 0000000000..2b42aa174f --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_event_encoder_gatts.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup ble_rpc_event_encoder_gatts GATTS Events Encoder + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief Event encoder for S110 SoftDevice serialization. + * + * @details This module provides functions for serializing S110 SoftDevice events. + * + */ +#ifndef BLE_RPC_EVENT_ENCODER_GATTS_H__ +#define BLE_RPC_EVENT_ENCODER_GATTS_H__ + +#include +#include + +/**@brief Function for encoding a @ref ble_evt_t GATTS event. + * + * @param[in] p_ble_evt S110 SoftDevice event to serialize. + * @param[out] p_buffer Pointer to a buffer for the encoded event. + * + * @return Number of bytes encoded. + */ +uint32_t ble_rpc_evt_gatts_encode(ble_evt_t * p_ble_evt, uint8_t * p_buffer); + +#endif // BLE_RPC_EVENT_ENCODER_GATTS_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_pkt_receiver.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_pkt_receiver.h new file mode 100644 index 0000000000..6048b66301 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/ble/rpc/ble_rpc_pkt_receiver.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup rpc_pkt_receiver Packet Receiver + * @{ + * @ingroup ble_sdk_lib_serialization + * + * @brief This module is used for processing the Command Response packets and Event packets. + */ + +#ifndef BLE_RPC_PKT_RECEIVER_H__ +#define BLE_RPC_PKT_RECEIVER_H__ + +#include + +/**@brief Function for initializing the BLE S110 RPC Packet Receiver module. + * + * @return NRF_SUCCESS upon success, any other upon failure. + */ +uint32_t ble_rpc_pkt_receiver_init(void); + +#endif + +/** @} **/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nordic_common.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nordic_common.h new file mode 100644 index 0000000000..620c31a681 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nordic_common.h @@ -0,0 +1,73 @@ +/* Copyright (c) 2008 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + */ + +/** @file + * @brief Common defines and macros for firmware developed by Nordic Semiconductor. + */ + +#ifndef NORDIC_COMMON_H__ +#define NORDIC_COMMON_H__ + +#include "nordic_global.h" + +/** Swaps the upper byte with the lower byte in a 16 bit variable */ +//lint -emacro((572),SWAP) // Suppress warning 572 "Excessive shift value" +#define SWAP(x) ((((x)&0xFF)<<8)|(((x)>>8)&0xFF)) + +/** The upper 8 bits of a 16 bit value */ +#define MSB(a) (((a) & 0xFF00) >> 8) +/** The lower 8 bits (of a 16 bit value) */ +#define LSB(a) ((a) & 0xFF) + +/** Leaves the minimum of the two arguments */ +/*lint -emacro(506, MIN) */ /* Suppress "Constant value Boolean */ +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +/** Leaves the maximum of the two arguments */ +/*lint -emacro(506, MAX) */ /* Suppress "Constant value Boolean */ +#define MAX(a, b) ((a) < (b) ? (b) : (a)) + +#define BIT_0 0x01 /**< The value of bit 0 */ +#define BIT_1 0x02 /**< The value of bit 1 */ +#define BIT_2 0x04 /**< The value of bit 2 */ +#define BIT_3 0x08 /**< The value of bit 3 */ +#define BIT_4 0x10 /**< The value of bit 4 */ +#define BIT_5 0x20 /**< The value of bit 5 */ +#define BIT_6 0x40 /**< The value of bit 6 */ +#define BIT_7 0x80 /**< The value of bit 7 */ +#define BIT_8 0x0100 /**< The value of bit 8 */ +#define BIT_9 0x0200 /**< The value of bit 9 */ +#define BIT_10 0x0400 /**< The value of bit 10 */ +#define BIT_11 0x0800 /**< The value of bit 11 */ +#define BIT_12 0x1000 /**< The value of bit 12 */ +#define BIT_13 0x2000 /**< The value of bit 13 */ +#define BIT_14 0x4000 /**< The value of bit 14 */ +#define BIT_15 0x8000 /**< The value of bit 15 */ +#define BIT_16 0x00010000 /**< The value of bit 16 */ +#define BIT_17 0x00020000 /**< The value of bit 17 */ +#define BIT_18 0x00040000 /**< The value of bit 18 */ +#define BIT_19 0x00080000 /**< The value of bit 19 */ +#define BIT_20 0x00100000 /**< The value of bit 20 */ +#define BIT_21 0x00200000 /**< The value of bit 21 */ +#define BIT_22 0x00400000 /**< The value of bit 22 */ +#define BIT_23 0x00800000 /**< The value of bit 23 */ +#define BIT_24 0x01000000 /**< The value of bit 24 */ +#define BIT_25 0x02000000 /**< The value of bit 25 */ +#define BIT_26 0x04000000 /**< The value of bit 26 */ +#define BIT_27 0x08000000 /**< The value of bit 27 */ +#define BIT_28 0x10000000 /**< The value of bit 28 */ +#define BIT_29 0x20000000 /**< The value of bit 29 */ +#define BIT_30 0x40000000 /**< The value of bit 30 */ +#define BIT_31 0x80000000 /**< The value of bit 31 */ + +#define UNUSED_VARIABLE(X) ((void)(X)) +#define UNUSED_PARAMETER(X) UNUSED_VARIABLE(X) + +#endif // NORDIC_COMMON_H__ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_assert.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_assert.h new file mode 100644 index 0000000000..62fef5987d --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_assert.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ + +/** @file + * @brief Utilities for verifying program logic + */ + +#ifndef NRF_ASSERT_H_ +#define NRF_ASSERT_H_ + +#include +#include "nordic_global.h" + +#if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) + +/** @brief Function for handling assertions. + * + * + * @note + * This function is called when an assertion has triggered. + * + * + * @post + * All hardware is put into an idle non-emitting state (in particular the radio is highly + * important to switch off since the radio might be in a state that makes it send + * packets continiously while a typical final infinit ASSERT loop is executing). + * + * + * @param line_num The line number where the assertion is called + * @param file_name Pointer to the file name + */ +void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); + +/*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ +/*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \ + +/** @brief Function for checking intended for production code. + * + * Check passes if "expr" evaluates to true. */ +#define ASSERT(expr) \ +if (expr) \ +{ \ +} \ +else \ +{ \ + assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \ +} +#else +#define ASSERT(expr) //!< Assert empty when disabled +void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); +#endif /* defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) */ + +#endif /* NRF_ASSERT_H_ */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_ecb.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_ecb.h new file mode 100644 index 0000000000..c36103a550 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_ecb.h @@ -0,0 +1,67 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic + * Semiconductor ASA.Terms and conditions of usage are described in detail + * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + * $LastChangedRevision: 13999 $ + */ + +/** + * @file + * @brief ECB driver API. + */ + +#ifndef NRF_ECB_H__ +#define NRF_ECB_H__ + +/** + * @defgroup nrf_ecb AES ECB encryption + * @{ + * @ingroup nrf_drivers + * @brief Driver for the nRF51 AES Electronic Code Book (ECB) peripheral. + * + * In order to encrypt and decrypt data the peripheral must be powered on + * using nrf_ecb_init() and then the key set using nrf_ecb_set_key. + */ + +#include +#include "nordic_global.h" + +/** + * Initialize and power on the ECB peripheral. + * + * Allocates memory for the ECBDATAPTR. + * @retval true Initialization was successful. + * @retval false Powering up failed. + */ +bool nrf_ecb_init(void); + +/** + * Encrypt/decrypt 16-byte data using current key. + * + * The function avoids unnecessary copying of data if the point to the + * correct locations in the ECB data structure. + * + * @param dst Result of encryption/decryption. 16 bytes will be written. + * @param src Source with 16-byte data to be encrypted/decrypted. + * + * @retval true If the encryption operation completed. + * @retval false If the encryption operation did not complete. + */ +bool nrf_ecb_crypt(uint8_t * dst, const uint8_t * src); + +/** + * Set the key to be used for encryption/decryption. + * + * @param key Pointer to key. 16 bytes will be read. + */ +void nrf_ecb_set_key(const uint8_t * key); + +#endif // NRF_ECB_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_gpio.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_gpio.h new file mode 100644 index 0000000000..50c6c0f8b2 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_gpio.h @@ -0,0 +1,411 @@ +#ifndef NRF_GPIO_H__ +#define NRF_GPIO_H__ + +#include "nordic_global.h" +#include "nrf51.h" +#include "nrf51_bitfields.h" + +/** + * @defgroup nrf_gpio GPIO abstraction + * @{ + * @ingroup nrf_drivers + * @brief GPIO pin abstraction and port abstraction for reading and writing byte-wise to GPIO ports. + * + * Here, the GPIO ports are defined as follows: + * - Port 0 -> pin 0-7 + * - Port 1 -> pin 8-15 + * - Port 2 -> pin 16-23 + * - Port 3 -> pin 24-31 + */ + +/** + * @enum nrf_gpio_port_dir_t + * @brief Enumerator used for setting the direction of a GPIO port. + */ +typedef enum +{ + NRF_GPIO_PORT_DIR_OUTPUT, ///< Output + NRF_GPIO_PORT_DIR_INPUT ///< Input +} nrf_gpio_port_dir_t; + +/** + * @enum nrf_gpio_pin_dir_t + * Pin direction definitions. + */ +typedef enum +{ + NRF_GPIO_PIN_DIR_INPUT, ///< Input + NRF_GPIO_PIN_DIR_OUTPUT ///< Output +} nrf_gpio_pin_dir_t; + +/** + * @enum nrf_gpio_port_select_t + * @brief Enumerator used for selecting between port 0 - 3. + */ +typedef enum +{ + NRF_GPIO_PORT_SELECT_PORT0 = 0, ///< Port 0 (GPIO pin 0-7) + NRF_GPIO_PORT_SELECT_PORT1, ///< Port 1 (GPIO pin 8-15) + NRF_GPIO_PORT_SELECT_PORT2, ///< Port 2 (GPIO pin 16-23) + NRF_GPIO_PORT_SELECT_PORT3, ///< Port 3 (GPIO pin 24-31) +} nrf_gpio_port_select_t; + +/** + * @enum nrf_gpio_pin_pull_t + * @brief Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration + */ +typedef enum +{ + NRF_GPIO_PIN_NOPULL = GPIO_PIN_CNF_PULL_Disabled, ///< Pin pullup resistor disabled + NRF_GPIO_PIN_PULLDOWN = GPIO_PIN_CNF_PULL_Pulldown, ///< Pin pulldown resistor enabled + NRF_GPIO_PIN_PULLUP = GPIO_PIN_CNF_PULL_Pullup, ///< Pin pullup resistor enabled +} nrf_gpio_pin_pull_t; + +/** + * @enum nrf_gpio_pin_sense_t + * @brief Enumerator used for selecting the pin to sense high or low level on the pin input. + */ +typedef enum +{ + NRF_GPIO_PIN_NOSENSE = GPIO_PIN_CNF_SENSE_Disabled, ///< Pin sense level disabled. + NRF_GPIO_PIN_SENSE_LOW = GPIO_PIN_CNF_SENSE_Low, ///< Pin sense low level. + NRF_GPIO_PIN_SENSE_HIGH = GPIO_PIN_CNF_SENSE_High, ///< Pin sense high level. +} nrf_gpio_pin_sense_t; + +/** + * @brief Function for configuring the GPIO pin range as outputs with normal drive strength. + * This function can be used to configure pin range as simple output with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). + * + * @param pin_range_start specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30) + * + * @param pin_range_end specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30) + * + * @note For configuring only one pin as output use @ref nrf_gpio_cfg_output + * Sense capability on the pin is disabled, and input is disconnected from the buffer as the pins are configured as output. + */ +static __INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + for (; pin_range_start <= pin_range_end; pin_range_start++) + { + NRF_GPIO->PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + } +} + +/** + * @brief Function for configuring the GPIO pin range as inputs with given initial value set, hiding inner details. + * This function can be used to configure pin range as simple input. + * + * @param pin_range_start specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30) + * + * @param pin_range_end specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30) + * + * @param pull_config State of the pin range pull resistor (no pull, pulled down or pulled high) + * + * @note For configuring only one pin as input use @ref nrf_gpio_cfg_input + * Sense capability on the pin is disabled, and input is connected to buffer so that the GPIO->IN register is readable + */ +static __INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start, uint32_t pin_range_end, nrf_gpio_pin_pull_t pull_config) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + for (; pin_range_start <= pin_range_end; pin_range_start++) + { + NRF_GPIO->PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (pull_config << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); + } +} + +/** + * @brief Function for configuring the given GPIO pin number as output with given initial value set, hiding inner details. + * This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). + * + * @param pin_number specifies the pin number of gpio pin numbers to be configured (allowed values 0-30) + * + * @note Sense capability on the pin is disabled, and input is disconnected from the buffer as the pins are configured as output. + */ +static __INLINE void nrf_gpio_cfg_output(uint32_t pin_number) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); +} + +/** + * @brief Function for configuring the given GPIO pin number as input with given initial value set, hiding inner details. + * This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). + * + * @param pin_number specifies the pin number of gpio pin numbers to be configured (allowed values 0-30) + * + * @param pull_config State of the pin range pull resistor (no pull, pulled down or pulled high) + * + * @note Sense capability on the pin is disabled, and input is connected to buffer so that the GPIO->IN register is readable + */ +static __INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (pull_config << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); +} + +/** + * @brief Function for configuring the given GPIO pin number as input with given initial value set, hiding inner details. + * This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). + * Sense capability on the pin is configurable, and input is connected to buffer so that the GPIO->IN register is readable. + * + * @param pin_number specifies the pin number of gpio pin numbers to be configured (allowed values 0-30). + * + * @param pull_config state of the pin pull resistor (no pull, pulled down or pulled high). + * + * @param sense_config sense level of the pin (no sense, sense low or sense high). + */ +static __INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config, nrf_gpio_pin_sense_t sense_config) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + NRF_GPIO->PIN_CNF[pin_number] = (sense_config << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (pull_config << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); +} + +/** + * @brief Function for setting the direction for a GPIO pin. + * + * @param pin_number specifies the pin number [0:31] for which to + * set the direction. + * + * @param direction specifies the direction + */ +static __INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction) +{ + if(direction == NRF_GPIO_PIN_DIR_INPUT) + { + NRF_GPIO->PIN_CNF[pin_number] = + (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); + } + else + { + NRF_GPIO->DIRSET = (1UL << pin_number); + } +} + +/** + * @brief Function for setting a GPIO pin. + * + * Note that the pin must be configured as an output for this + * function to have any effect. + * + * @param pin_number specifies the pin number [0:31] to + * set. + */ +static __INLINE void nrf_gpio_pin_set(uint32_t pin_number) +{ + NRF_GPIO->OUTSET = (1UL << pin_number); +} + +/** + * @brief Function for clearing a GPIO pin. + * + * Note that the pin must be configured as an output for this + * function to have any effect. + * + * @param pin_number specifies the pin number [0:31] to + * clear. + */ +static __INLINE void nrf_gpio_pin_clear(uint32_t pin_number) +{ + NRF_GPIO->OUTCLR = (1UL << pin_number); +} + +/** + * @brief Function for toggling a GPIO pin. + * + * Note that the pin must be configured as an output for this + * function to have any effect. + * + * @param pin_number specifies the pin number [0:31] to + * toggle. + */ +static __INLINE void nrf_gpio_pin_toggle(uint32_t pin_number) +{ + NRF_GPIO->OUT ^= (1UL << pin_number); +} + +/** + * @brief Function for writing a value to a GPIO pin. + * + * Note that the pin must be configured as an output for this + * function to have any effect. + * + * @param pin_number specifies the pin number [0:31] to + * write. + * + * @param value specifies the value to be written to the pin. + * @arg 0 clears the pin + * @arg >=1 sets the pin. + */ +static __INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value) +{ + if (value == 0) + { + nrf_gpio_pin_clear(pin_number); + } + else + { + nrf_gpio_pin_set(pin_number); + } +} + +/** + * @brief Function for reading the input level of a GPIO pin. + * + * Note that the pin must have input connected for the value + * returned from this function to be valid. + * + * @param pin_number specifies the pin number [0:31] to + * read. + * + * @return + * @retval 0 if the pin input level is low. + * @retval 1 if the pin input level is high. + * @retval > 1 should never occur. + */ +static __INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number) +{ + return ((NRF_GPIO->IN >> pin_number) & 1UL); +} + +/** + * @brief Generic function for writing a single byte of a 32 bit word at a given + * address. + * + * This function should not be called from outside the nrf_gpio + * abstraction layer. + * + * @param word_address is the address of the word to be written. + * + * @param byte_no is the the word byte number (0-3) to be written. + * + * @param value is the value to be written to byte "byte_no" of word + * at address "word_address" + */ +static __INLINE void nrf_gpio_word_byte_write(volatile uint32_t * word_address, uint8_t byte_no, uint8_t value) +{ + *((volatile uint8_t*)(word_address) + byte_no) = value; +} + +/** + * @brief Generic function for reading a single byte of a 32 bit word at a given + * address. + * + * This function should not be called from outside the nrf_gpio + * abstraction layer. + * + * @param word_address is the address of the word to be read. + * + * @param byte_no is the the byte number (0-3) of the word to be read. + * + * @return byte "byte_no" of word at address "word_address". + */ +static __INLINE uint8_t nrf_gpio_word_byte_read(const volatile uint32_t* word_address, uint8_t byte_no) +{ + return (*((const volatile uint8_t*)(word_address) + byte_no)); +} + +/** + * @brief Function for setting the direction of a port. + * + * @param port is the port for which to set the direction. + * + * @param dir direction to be set for this port. + */ +static __INLINE void nrf_gpio_port_dir_set(nrf_gpio_port_select_t port, nrf_gpio_port_dir_t dir) +{ + if (dir == NRF_GPIO_PORT_DIR_OUTPUT) + { + nrf_gpio_word_byte_write(&NRF_GPIO->DIRSET, port, 0xFF); + } + else + { + nrf_gpio_range_cfg_input(port*8, (port+1)*8-1, NRF_GPIO_PIN_NOPULL); + } +} + +/** + * @brief Function for reading a GPIO port. + * + * @param port is the port to read. + * + * @return the input value on this port. + */ +static __INLINE uint8_t nrf_gpio_port_read(nrf_gpio_port_select_t port) +{ + return nrf_gpio_word_byte_read(&NRF_GPIO->IN, port); +} + +/** + * @brief Function for writing to a GPIO port. + * + * @param port is the port to write. + * + * @param value is the value to write to this port. + * + * @sa nrf_gpio_port_dir_set() + */ +static __INLINE void nrf_gpio_port_write(nrf_gpio_port_select_t port, uint8_t value) +{ + nrf_gpio_word_byte_write(&NRF_GPIO->OUT, port, value); +} + +/** + * @brief Function for setting individual pins on GPIO port. + * + * @param port is the port for which to set the pins. + * + * @param set_mask is a mask specifying which pins to set. A bit + * set to 1 indicates that the corresponding port pin shall be + * set. + * + * @sa nrf_gpio_port_dir_set() + */ +static __INLINE void nrf_gpio_port_set(nrf_gpio_port_select_t port, uint8_t set_mask) +{ + nrf_gpio_word_byte_write(&NRF_GPIO->OUTSET, port, set_mask); +} + +/** + * @brief Function for clearing individual pins on GPIO port. + * + * @param port is the port for which to clear the pins. + * + * @param clr_mask is a mask specifying which pins to clear. A bit + * set to 1 indicates that the corresponding port pin shall be + * cleared. + * + * @sa nrf_gpio_port_dir_set() + */ +static __INLINE void nrf_gpio_port_clear(nrf_gpio_port_select_t port, uint8_t clr_mask) +{ + nrf_gpio_word_byte_write(&NRF_GPIO->OUTCLR, port, clr_mask); +} + +/** @} */ + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_nvmc.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_nvmc.h new file mode 100644 index 0000000000..7c68c0d541 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_nvmc.h @@ -0,0 +1,91 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic + * Semiconductor ASA.Terms and conditions of usage are described in detail + * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + * $LastChangedRevision: 17685 $ + */ + +/** + * @file + * @brief NMVC driver API. + */ + +#ifndef NRF_NVMC_H__ +#define NRF_NVMC_H__ + +#include +#include "nordic_global.h" + + +/** + * @defgroup nrf_nvmc Non-volatile memory controller + * @{ + * @ingroup nrf_drivers + * @brief Driver for the nRF51 NVMC peripheral. + * + * This driver allows writing to the non-volatile memory (NVM) regions + * of the nRF51. In order to write to NVM the controller must be powered + * on and the relevant page must be erased. + * + */ + + +/** + * @brief Erase a page in flash. This is required before writing to any + * address in the page. + * + * @param address Start address of the page. + */ +void nrf_nvmc_page_erase(uint32_t address); + + +/** + * @brief Write a single byte to flash. + * + * The function reads the word containing the byte, and then + * rewrites the entire word. + * + * @param address Address to write to. + * @param value Value to write. + */ +void nrf_nvmc_write_byte(uint32_t address , uint8_t value); + + +/** + * @brief Write a 32-bit word to flash. + * @param address Address to write to. + * @param value Value to write. + */ +void nrf_nvmc_write_word(uint32_t address, uint32_t value); + + +/** + * @brief Write consecutive bytes to flash. + * + * @param address Address to write to. + * @param src Pointer to data to copy from. + * @param num_bytes Number of bytes in src to write. + */ +void nrf_nvmc_write_bytes(uint32_t address, const uint8_t * src, uint32_t num_bytes); + + +/** + @ @brief Write consecutive words to flash. + * + * @param address Address to write to. + * @param src Pointer to data to copy from. + * @param num_words Number of bytes in src to write. + */ +void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_words); + + +#endif // NRF_NVMC_H__ +/** @} */ + + diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_temp.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_temp.h new file mode 100644 index 0000000000..74a3df368b --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/nrf_temp.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#ifndef NRF_TEMP_H__ +#define NRF_TEMP_H__ + +#include "nordic_global.h" +#include "nrf51.h" + +/** +* @defgroup nrf_temperature TEMP (temperature) abstraction +* @{ +* @ingroup nrf_drivers temperature_example +* @brief Temperature module init and read functions. +* +*/ + + + +/** + * @brief Function for preparing the temp module for temperature measurement. + * + * This function initializes the TEMP module and writes to the hidden configuration register. + * + * @param none + */ +static __INLINE void nrf_temp_init(void) +{ + /**@note Workaround for PAN_028 rev2.0A anomaly 31 - TEMP: Temperature offset value has to be manually loaded to the TEMP module */ + *(uint32_t *) 0x4000C504 = 0; +} + + + +#define MASK_SIGN (0x00000200UL) +#define MASK_SIGN_EXTENSION (0xFFFFFC00UL) + +/** + * @brief Function for reading temperature measurement. + * + * The function reads the 10 bit 2's complement value and transforms it to a 32 bit 2's complement value. + * + * @param none + */ +static __INLINE int32_t nrf_temp_read(void) +{ + /**@note Workaround for PAN_028 rev2.0A anomaly 28 - TEMP: Negative measured values are not represented correctly */ + return ((NRF_TEMP->TEMP & MASK_SIGN) != 0) ? (NRF_TEMP->TEMP | MASK_SIGN_EXTENSION) : (NRF_TEMP->TEMP); +} + +/** @} */ + +#endif diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble.h new file mode 100644 index 0000000000..4f2ab86089 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble.h @@ -0,0 +1,303 @@ +/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ +/** + @addtogroup BLE_COMMON BLE SoftDevice Common + @{ + @defgroup ble_api Events, type definitions and API calls + @{ + + @brief Module independent events, type definitions and API calls for the S110 SoftDevice. + + */ + +#ifndef BLE_H__ +#define BLE_H__ + +#include "nordic_global.h" +#include "ble_ranges.h" +#include "ble_types.h" +#include "ble_gap.h" +#include "ble_l2cap.h" +#include "ble_gatt.h" +#include "ble_gattc.h" +#include "ble_gatts.h" + +/** + * @brief Common API SVC numbers. + */ +enum BLE_COMMON_SVCS +{ + SD_BLE_EVT_GET = BLE_SVC_BASE, /**< Get an event from the pending events queue. */ + SD_BLE_TX_BUFFER_COUNT_GET, /**< Get the total number of available application transmission buffers from the stack. */ + SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */ + SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */ + SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */ + SD_BLE_VERSION_GET, /**< Get the local version information (company id, LMP Version, LMP Subversion). */ + SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */ +}; + +/** @brief Required pointer alignment for BLE Events. +*/ +#define BLE_EVTS_PTR_ALIGNMENT 4 + +/** @defgroup BLE_USER_MEM_TYPES User Memory Types + * @{ */ +#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */ +#define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */ +/** @} */ + +/** @brief Maximum number of Vendor Specific UUIDs. +*/ +#define BLE_UUID_VS_MAX_COUNT 10 + +/** + * @brief BLE Module Independent Event IDs. + */ +enum BLE_COMMON_EVTS +{ + BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /**< Transmission Complete. */ + BLE_EVT_USER_MEM_REQUEST, /**< User Memory request. */ + BLE_EVT_USER_MEM_RELEASE /**< User Memory release. */ +}; + +/**@brief User Memory Block. */ +typedef struct +{ + uint8_t* p_mem; /**< Pointer to the start of the user memory block. */ + uint16_t len; /**< Length in bytes of the user memory block. */ +} ble_user_mem_block_t; + +/** + * @brief TX complete event. + */ +typedef struct +{ + uint8_t count; /**< Number of packets transmitted. */ +} ble_evt_tx_complete_t; + +/**@brief Event structure for BLE_EVT_USER_MEM_REQUEST. */ +typedef struct +{ + uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */ +} ble_evt_user_mem_request_t; + +/**@brief Event structure for BLE_EVT_USER_MEM_RELEASE. */ +typedef struct +{ + uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */ + ble_user_mem_block_t mem_block; /**< User memory block */ +} ble_evt_user_mem_release_t; + + +/**@brief Event structure for events not associated with a specific function module. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which this event occured. */ + union + { + ble_evt_tx_complete_t tx_complete; /**< Transmission Complete. */ + ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */ + ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */ + } params; +} ble_common_evt_t; + +/**@brief BLE Event header. */ +typedef struct +{ + uint16_t evt_id; /**< Value from a BLE__EVT series. */ + uint16_t evt_len; /**< Length in octets excluding this header. */ +} ble_evt_hdr_t; + +/**@brief Common BLE Event type, wrapping the module specific event reports. */ +typedef struct +{ + ble_evt_hdr_t header; /**< Event header. */ + union + { + ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */ + ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */ + ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */ + ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */ + ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */ + } evt; +} ble_evt_t; + + +/** + * @brief Version Information. + */ +typedef struct +{ + uint8_t version_number; /**< LMP Version number for BT 4.0 spec is 6 (https://www.bluetooth.org/technical/assignednumbers/link_layer.htm). */ + uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */ + uint16_t subversion_number; /**< LMP Sub Version number corresponds to the SoftDevice Config ID. */ +} ble_version_t; + + +/**@brief Get an event from the pending events queue. + * + * @param[in] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length. This buffer must be 4-byte aligned in memory. + * @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length. + * + * @details This call allows the application to pull a BLE event from the BLE stack. The application is signalled that an event is + * available from the BLE Stack by the triggering of the SD_EVT_IRQn interrupt (mapped to IRQ 22). + * The application is free to choose whether to call this function from thread mode (main context) or directly from the Interrupt Service Routine + * that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher priority than the application, this function should be called + * in a loop (until @ref NRF_ERROR_NOT_FOUND is returned) every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the stack. + * Failure to do so could potentially leave events in the internal queue without the application being aware of this fact. + * Sizing the p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to be copied into + * application memory. If the buffer provided is not large enough to fit the entire contents of the event, @ref NRF_ERROR_DATA_SIZE will be returned + * and the application can then call again with a larger buffer size. + * Please note that because of the variable length nature of some events, sizeof(ble_evt_t) will not always be large enough to fit certain events, + * and so it is the application's responsability to provide an amount of memory large enough so that the relevant event is copied in full. + * The application may "peek" the event length by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return. + * + * @note The pointer supplied must be aligned to the extend defined by @ref BLE_EVTS_PTR_ALIGNMENT + * + * @return @ref NRF_SUCCESS Event pulled and stored into the supplied buffer. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied. + * @return @ref NRF_ERROR_NOT_FOUND No events ready to be pulled. + * @return @ref NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer. + */ +SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t* p_dest, uint16_t *p_len)); + + +/**@brief Get the total number of available application transmission buffers in the BLE stack. + * + * @details This call allows the application to obtain the total number of + * transmission buffers available for application data. Please note that + * this does not give the number of free buffers, but rather the total amount of them. + * The application has two options to handle its own application transmission buffers: + * - Use a simple arithmetic calculation: at boot time the application should use this function + * to find out the total amount of buffers available to it and store it in a variable. + * Every time a packet that consumes an application buffer is sent using any of the + * exposed functions in this BLE API, the application should decrement that variable. + * Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event is received by the application + * it should retrieve the count field in such event and add that number to the same + * variable storing the number of available packets. + * This mechanism allows the application to be aware at any time of the number of + * application packets available in the BLE stack's internal buffers, and therefore + * it can know with certainty whether it is possible to send more data or it has to + * wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds. + * - Choose to simply not keep track of available buffers at all, and instead handle the + * @ref BLE_ERROR_NO_TX_BUFFERS error by queueing the packet to be transmitted and + * try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives. + * + * The API functions that may consume an application buffer depending on + * the parameters supplied to them can be found below: + * + * - @ref sd_ble_gattc_write (write witout response only) + * - @ref sd_ble_gatts_hvx (notifications only) + * - @ref sd_ble_l2cap_tx (all packets) + * + * @param[out] p_count Pointer to a uint8_t which will contain the number of application transmission buffers upon + * successful return. + * + * @return @ref NRF_SUCCESS Number of application transmission buffers retrieved successfully. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_TX_BUFFER_COUNT_GET, uint32_t, sd_ble_tx_buffer_count_get(uint8_t* p_count)); + + +/**@brief Add a Vendor Specific UUID. + * + * @details This call enables the application to add a vendor specific UUID to the BLE stack's table, + * for later use all other modules and APIs. This then allows the application to use the shorter, + * 24-bit @ref ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to + * check for lengths and having split code paths. The way that this is accomplished is by extending the + * grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The + * type field in the @ref ble_uuid_t structure is an index (relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN) + * to the table populated by multiple calls to this function, and the uuid field in the same structure + * contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to the + * application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536, + * although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array. + * + * @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by + * the 16-bit uuid field in @ref ble_uuid_t. + * + * + * @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding + * bytes 12 and 13. + * @param[out] p_uuid_type Pointer where the type field in @ref ble_uuid_t corresponding to this UUID will be stored. + * + * @return @ref NRF_SUCCESS Successfully added the Vendor Specific UUID. + * @return @ref NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid. + * @return @ref NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs. + * @return @ref NRF_ERROR_FORBIDDEN If p_vs_uuid has already been added to the VS UUID table. + */ +SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const * const p_vs_uuid, uint8_t * const p_uuid_type)); + + +/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure. + * + * @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared + * to the corresponding ones in each entry of the table of vendor specific UUIDs pouplated with @ref sd_ble_uuid_vs_add + * to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index + * relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type. + * + * @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE. + * + * @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes). + * @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes. + * @param[in,out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in. + * + * @return @ref NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_LENGTH Invalid UUID length. + * @return @ref NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs. + */ +SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const * const p_uuid_le, ble_uuid_t * const p_uuid)); + + +/** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit). + * + * @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validitiy and size of p_uuid is computed. + * + * @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes. + * @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes). + * @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored. + * + * @return @ref NRF_SUCCESS Successfully encoded into the buffer. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid UUID type. + */ +SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const * const p_uuid, uint8_t * const p_uuid_le_len, uint8_t * const p_uuid_le)); + + +/**@brief Get Version Information. + * + * @details This call allows the application to get the BLE stack version information. + * + * @param[in] p_version Pointer to ble_version_t structure to be filled in. + * + * @return @ref NRF_SUCCESS Version information stored successfully. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_BUSY The stack is busy (typically doing a locally-initiated disconnection procedure). + */ +SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t * p_version)); + + +/**@brief Provide a user memory block. + * + * @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_block Pointer to a user memory block structure. + * + * @return @ref NRF_SUCCESS Successfully queued a response to the peer. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_STATE No execute write request pending. + */ +SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t *p_block)); + +#endif /* BLE_H__ */ + +/** + @} + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_err.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_err.h new file mode 100644 index 0000000000..20eb843ad3 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_err.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ + /** + @addtogroup BLE_COMMON + @{ + @addtogroup nrf_error + @{ + @ingroup BLE_COMMON + @} + + @defgroup ble_err General error codes + @{ + + @brief General error code definitions for the BLE API. + + @ingroup BLE_COMMON +*/ +#ifndef NRF_BLE_ERR_H__ +#define NRF_BLE_ERR_H__ + +#include "nordic_global.h" +#include "nrf_error.h" + +/* @defgroup BLE_ERRORS Error Codes + * @{ */ +#define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x001) /**< Invalid connection handle. */ +#define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid attribute handle. */ +#define BLE_ERROR_NO_TX_BUFFERS (NRF_ERROR_STK_BASE_NUM+0x003) /**< Buffer capacity exceeded. */ +/** @} */ + + +/** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges + * @brief Assignment of subranges for module specific error codes. + * @note For specific error codes, see ble_.h or ble_error_.h. + * @{ */ +#define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */ +#define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */ +#define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */ +#define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */ +/** @} */ + +#endif + + +/** + @} + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gap.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gap.h new file mode 100644 index 0000000000..1d70885156 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gap.h @@ -0,0 +1,896 @@ +/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ +/** + @addtogroup BLE_GAP Generic Access Profile (GAP) + @{ + @brief Definitions and prototypes for the GAP interface. + */ + +#ifndef BLE_GAP_H__ +#define BLE_GAP_H__ + +#include "nordic_global.h" +#include "ble_types.h" +#include "ble_ranges.h" +#include "nrf_svc.h" + +/** + * @brief GAP API SVC numbers. + */ +enum BLE_GAP_SVCS +{ + SD_BLE_GAP_ADDRESS_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */ + SD_BLE_GAP_ADDRESS_GET, /**< Get own Bluetooth Address. */ + SD_BLE_GAP_ADV_DATA_SET, /**< Set Advertisement Data. */ + SD_BLE_GAP_ADV_START, /**< Start Advertising. */ + SD_BLE_GAP_ADV_STOP, /**< Stop Advertising. */ + SD_BLE_GAP_CONN_PARAM_UPDATE, /**< Connection Parameter Update. */ + SD_BLE_GAP_DISCONNECT, /**< Disconnect. */ + SD_BLE_GAP_TX_POWER_SET, /**< Set TX Power. */ + SD_BLE_GAP_APPEARANCE_SET, /**< Set Appearance. */ + SD_BLE_GAP_APPEARANCE_GET, /**< Get Appearance. */ + SD_BLE_GAP_PPCP_SET, /**< Set PPCP. */ + SD_BLE_GAP_PPCP_GET, /**< Get PPCP. */ + SD_BLE_GAP_DEVICE_NAME_SET, /**< Set Device Name. */ + SD_BLE_GAP_DEVICE_NAME_GET, /**< Get Device Name. */ + SD_BLE_GAP_AUTHENTICATE, /**< Initiate Pairing/Bonding. */ + SD_BLE_GAP_SEC_PARAMS_REPLY, /**< Reply with Security Parameters. */ + SD_BLE_GAP_AUTH_KEY_REPLY, /**< Reply with an authentication key. */ + SD_BLE_GAP_SEC_INFO_REPLY, /**< Reply with Security Information. */ + SD_BLE_GAP_CONN_SEC_GET, /**< Obtain connection security level. */ + SD_BLE_GAP_RSSI_START, /**< Start reporting of changes in RSSI. */ + SD_BLE_GAP_RSSI_STOP, /**< Stop reporting of changes in RSSI. */ +}; + + +/** @addtogroup BLE_GAP_DEFINES Defines + * @{ */ + +/** @defgroup BLE_ERRORS_GAP SVC return values specific to GAP + * @{ */ +#define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */ +#define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */ +#define BLE_ERROR_GAP_INVALID_BLE_ADDR (NRF_GAP_ERR_BASE + 0x002) /**< The upper two bits of the address do not correspond to the specified address type. */ +/** @} */ + + +/** @defgroup BLE_GAP_ROLES GAP Roles + * @note Not explicitly used in peripheral API, but will be relevant for central API. + * @{ */ +#define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */ +#define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */ +#define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */ +/** @} */ + + +/** @defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources + * @{ */ +#define BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT 0x00 /**< Advertisement timeout. */ +#define BLE_GAP_TIMEOUT_SRC_SECURITY_REQUEST 0x01 /**< Security request timeout. */ +/** @} */ + + +/** @defgroup BLE_GAP_ADDR_TYPES GAP Address types + * @{ */ +#define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random Static address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Private Resolvable address. */ +#define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Private Non-Resolvable address. */ +/** @} */ + + +/** @brief BLE address length. */ +#define BLE_GAP_ADDR_LEN 6 + + +/** @defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format + * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm + * @{ */ +#define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */ +#define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */ +#define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */ +#define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */ +#define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */ +#define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */ +#define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */ +#define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */ +#define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */ +#define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */ +#define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */ +#define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */ +#define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data. */ +#define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */ +#define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */ +#define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */ +#define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */ +/** @} */ + + +/** @defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags + * @{ */ +#define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */ +#define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */ +#define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */ +#define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */ +#define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */ +#define BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE (BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE Limited Discoverable Mode, BR/EDR not supported. */ +#define BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE (BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE General Discoverable Mode, BR/EDR not supported. */ +/** @} */ + + +/** @defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min + * @{ */ +#define BLE_GAP_ADV_INTERVAL_MIN 0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */ +#define BLE_GAP_ADV_NONCON_INTERVAL_MIN 0x00A0 /**< Minimum Advertising interval in 625 us units for non connectable mode, i.e. 100 ms. */ +#define BLE_GAP_ADV_INTERVAL_MAX 0x4000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */ + /** @} */ + + +/** @brief Maximum size of advertising data in octets. */ +#define BLE_GAP_ADV_MAX_SIZE 31 + + +/** @defgroup BLE_GAP_ADV_TYPES GAP Advertising types + * @{ */ +#define BLE_GAP_ADV_TYPE_ADV_IND 0x00 /**< Connectable undirected. */ +#define BLE_GAP_ADV_TYPE_ADV_DIRECT_IND 0x01 /**< Connectable directed. */ +#define BLE_GAP_ADV_TYPE_ADV_SCAN_IND 0x02 /**< Scannable undirected. */ +#define BLE_GAP_ADV_TYPE_ADV_NONCONN_IND 0x03 /**< Non connectable undirected. */ +/** @} */ + + +/** @defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies + * @{ */ +#define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */ +#define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */ +#define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */ +#define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */ +/** @} */ + + +/** @defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values + * @{ */ +#define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX 180 /**< Maximum advertising time in limited discoverable mode (TGAP(lim_adv_timeout) = 180s in spec (Addendum 2)). */ +#define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED 0 /**< Unlimited advertising in general discoverable mode. */ +/** @} */ + + +/** @defgroup BLE_GAP_DISC_MODES GAP Discovery modes + * @{ */ +#define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */ +#define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */ +#define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */ +/** @} */ + +/** @defgroup BLE_GAP_IO_CAPS GAP IO Capabilities + * @{ */ +#define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */ +#define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */ +#define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */ +#define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */ +#define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */ +/** @} */ + + +/** @defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types + * @{ */ +#define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */ +#define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */ +#define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */ +/** @} */ + +/** @defgroup BLE_GAP_SEC_STATUS GAP Security status + * @{ */ +#define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Successful parameters. */ +#define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */ +#define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */ +#define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user cancelled or other). */ +#define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */ +#define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */ +#define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */ +#define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */ +#define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */ +#define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */ +#define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */ +#define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */ +#define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */ +/** @} */ + +/** @defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources + * @{ */ +#define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */ +#define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */ +/** @} */ + +/** @defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits + * @{ */ +#define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connction interval specified in connect parameters. */ +#define BLE_GAP_CP_MIN_CONN_INTVL_MIN 0x0006 /**< Lowest mimimum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */ +#define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connction interval specified in connect parameters. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_MIN 0x0006 /**< Lowest maximum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */ +#define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */ +#define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x03E8 /**< Highest slave latency permitted, in connection events. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */ +#define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */ +/** @} */ + + +/**@brief GAP device name maximum length. */ +#define BLE_GAP_DEVNAME_MAX_LEN 31 + + +/** @defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters + * + * See @ref ble_gap_conn_sec_mode_t. + * @{ */ +/** @brief Set sec_mode pointed to by ptr to have no access rights.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0) +/** @brief Set sec_mode pointed to by ptr to require no protection, open link.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0) +/** @brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0) +/** @brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0) +/** @brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0) +/** @brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/ +#define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0) +/** @} */ + + +/**@brief GAP Security Key Length. */ +#define BLE_GAP_SEC_KEY_LEN 16 + +/**@brief Maximum amount of addresses in a whitelist. */ +#define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8) + +/**@brief Maximum amount of IRKs in a whitelist. + * @note The number of IRKs is limited to 8, even if the hardware supports more. + */ +#define BLE_GAP_WHITELIST_IRK_MAX_COUNT (8) + +/** @defgroup GAP_SEC_MODES GAP Security Modes + * @{ */ +#define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */ + +/** @} */ + + +/** @} */ + +/**@brief Bluetooth Low Energy address. */ +typedef struct +{ + uint8_t addr_type; /**< See @ref BLE_GAP_ADDR_TYPES. */ + uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. */ +} ble_gap_addr_t; + + +/**@brief GAP connection parameters. + * + * @note When ble_conn_params_t is received in an event, both min_conn_interval and + * max_conn_interval will be equal to the connection interval set by the central. + */ +typedef struct +{ + uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/ +} ble_gap_conn_params_t; + + +/**@brief GAP link requirements. + * + * See Bluetooth Core specification, Volume 3 Part C 10.2 for details. + * + * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n + * Security Mode 1 Level 1: No security is needed (aka open link).\n + * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n + * Security Mode 1 Level 3: MITM protected encrypted link required.\n + * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n + * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n + */ +typedef struct +{ + uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */ + uint8_t lv : 4; /**< Level (1, 2 or 3), 0 for no permissions at all. */ + +} ble_gap_conn_sec_mode_t; + + + +/**@brief GAP connection security status.*/ +typedef struct +{ + ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/ + uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets.*/ +} ble_gap_conn_sec_t; + + + +/**@brief Identity Resolving Key. */ +typedef struct +{ + uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */ +} ble_gap_irk_t; + + +/**@brief Whitelist structure. */ +typedef struct +{ + ble_gap_addr_t ** pp_addrs; /**< Pointer to array of device address pointers, pointing to addresses to be used in whitelist. NULL if none are given. */ + uint8_t addr_count; /**< Count of device addresses in array, up to @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT. */ + ble_gap_irk_t ** pp_irks; /**< Pointer to array of Identity Resolving Key (IRK) pointers, each pointing to an IRK in the whitelist. NULL if none are given. */ + uint8_t irk_count; /**< Count of IRKs in array, up to @ref BLE_GAP_WHITELIST_IRK_MAX_COUNT. */ +} ble_gap_whitelist_t; + + +/**@brief GAP advertising parameters.*/ +typedef struct +{ + uint8_t type; /**< See @ref BLE_GAP_ADV_TYPES. */ + ble_gap_addr_t* p_peer_addr; /**< For BLE_GAP_CONN_MODE_DIRECTED mode only, known peer address. */ + uint8_t fp; /**< Filter Policy, see @ref BLE_GAP_ADV_FILTER_POLICIES. */ + ble_gap_whitelist_t * p_whitelist; /**< Pointer to whitelist, NULL if none is given. */ + uint16_t interval; /**< Advertising interval between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s), see @ref BLE_GAP_ADV_INTERVALS. This parameter must be set to 0 if type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND. */ + uint16_t timeout; /**< Advertising timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. See also @ref BLE_GAP_ADV_TIMEOUT_VALUES. This parameter must be set to 0 if type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND. */ +} ble_gap_adv_params_t; + + +/**@brief GAP scanning parameters. */ +typedef struct +{ + uint8_t filter; /**< Filter based on discovery mode, see @ref BLE_GAP_DISC_MODES. */ + uint8_t active : 1; /**< If 1, perform active scanning (scan requests). */ + uint8_t selective : 1; /**< If 1, ignore unknown devices (non whitelisted). */ + uint16_t interval; /**< Scan interval between 0x0020 and 0x4000 in 0.625ms units (20ms to 10.24s). */ + uint16_t window; /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */ + uint16_t timeout; /**< Scan timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. */ +} ble_gap_scan_params_t; + + +/**@brief GAP security parameters. */ +typedef struct +{ + uint16_t timeout; /**< Timeout for SMP transactions or Security Request in seconds, see @ref sd_ble_gap_authenticate and @ref sd_ble_gap_sec_params_reply for more information. */ + uint8_t bond : 1; /**< Perform bonding. */ + uint8_t mitm : 1; /**< Man In The Middle protection required. */ + uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */ + uint8_t oob : 1; /**< Out Of Band data available. */ + uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. */ + uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */ +} ble_gap_sec_params_t; + + +/**@brief GAP Encryption Information. */ +typedef struct +{ + uint16_t div; /**< Encryption Diversifier. */ + uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */ + uint8_t auth : 1; /**< Authenticated Key. */ + uint8_t ltk_len : 7; /**< LTK length in octets. */ +} ble_gap_enc_info_t; + + +/**@brief GAP Master Identification. */ +typedef struct +{ + uint16_t ediv; /**< Encrypted Diversifier. */ + uint8_t rand[8]; /**< Random Number. */ +} ble_gap_master_id_t; + + +/**@brief GAP Identity Information. */ +typedef struct +{ + ble_gap_addr_t addr; /**< Bluetooth address to which this key applies. */ + uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Identity Resolution Key. */ +} ble_gap_id_info_t; + + +/**@brief GAP Signing Information. */ +typedef struct +{ + uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /* Connection Signature Resolving Key. */ +} ble_gap_sign_info_t; + + + +/** + * @brief GAP Event IDs. + * Those IDs uniquely identify an event coming from the stack to the application. + */ +enum BLE_GAP_EVTS +{ + BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connection established. */ + BLE_GAP_EVT_DISCONNECTED, /**< Disconnected from peer. */ + BLE_GAP_EVT_CONN_PARAM_UPDATE, /**< Connection Parameters updated. */ + BLE_GAP_EVT_SEC_PARAMS_REQUEST, /**< Request to provide security parameters. */ + BLE_GAP_EVT_SEC_INFO_REQUEST, /**< Request to provide security information. */ + BLE_GAP_EVT_PASSKEY_DISPLAY, /**< Request to display a passkey to the user. */ + BLE_GAP_EVT_AUTH_KEY_REQUEST, /**< Request to provide an authentication key. */ + BLE_GAP_EVT_AUTH_STATUS, /**< Authentication procedure completed with status. */ + BLE_GAP_EVT_CONN_SEC_UPDATE, /**< Connection security updated. */ + BLE_GAP_EVT_TIMEOUT, /**< Timeout expired. */ + BLE_GAP_EVT_RSSI_CHANGED, /**< Signal strength measurement report. */ +}; + + +/** @brief Event data for connected event. */ +typedef struct +{ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */ + uint8_t irk_match :1; /**< If 1, peer device's address resolved using an IRK. */ + uint8_t irk_match_idx :7; /**< Index in IRK list where the address was matched. */ + ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ +} ble_gap_evt_connected_t; + + +/** @brief Event data for disconnected event. */ +typedef struct +{ + uint8_t reason; /**< HCI error code. */ +} ble_gap_evt_disconnected_t; + + +/** @brief Event data for connection parameter update event. */ +typedef struct +{ + ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ +} ble_gap_evt_conn_param_update_t; + + +/** @brief Event data for security parameters request event. */ +typedef struct +{ + ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */ +} ble_gap_evt_sec_params_request_t; + + +/** @brief Event data for securito info request event. */ +typedef struct +{ + ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */ + uint16_t div; /**< Encryption diversifier for LTK lookup. */ + uint8_t enc_info : 1; /**< If 1, Encryption Information required. */ + uint8_t id_info : 1; /**< If 1, Identity Information required. */ + uint8_t sign_info : 1; /**< If 1, Signing Information required. */ +} ble_gap_evt_sec_info_request_t; + + +/** @brief Event data for passkey display event. */ +typedef struct +{ + uint8_t passkey[6]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */ +} ble_gap_evt_passkey_display_t; + + +/** @brief Event data for authentication key request event. */ +typedef struct +{ + uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */ +} ble_gap_evt_auth_key_request_t; + + +/** @brief Security levels supported. + * @note See Bluetooth Specification Version 4.0 Volume 3, Chapter 10. +*/ +typedef struct +{ + uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */ + uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */ + uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */ +} ble_gap_sec_levels_t; + + +/** @brief Keys that have been exchanged. */ +typedef struct +{ + uint8_t ltk : 1; /**< Long Term Key. */ + uint8_t ediv_rand : 1; /**< Encrypted Diversifier and Random value. */ + uint8_t irk : 1; /**< Identity Resolving Key. */ + uint8_t address : 1; /**< Public or static random address. */ + uint8_t csrk : 1; /**< Connection Signature Resolving Key. */ +} ble_gap_sec_keys_t; + + +/** @brief Event data for authentication status event. */ +typedef struct +{ + uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */ + uint8_t error_src; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */ + ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */ + ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */ + ble_gap_sec_keys_t periph_kex; /**< Bitmap stating which keys were exchanged (distributed) by the peripheral. */ + ble_gap_sec_keys_t central_kex; /**< Bitmap stating which keys were exchanged (distributed) by the central. */ + struct periph_keys_t + { + ble_gap_enc_info_t enc_info; /**< Peripheral's Encryption information. */ + } periph_keys; /**< Actual keys distributed from the Peripheral to the Central. */ + struct central_keys_t + { + ble_gap_irk_t irk; /**< Central's IRK. */ + ble_gap_addr_t id_info; /**< Central's Identity Info. */ + } central_keys; /**< Actual keys distributed from the Central to the Peripheral. */ +} ble_gap_evt_auth_status_t; + + +/** @brief Event data for connection security update event. */ +typedef struct +{ + ble_gap_conn_sec_t conn_sec; /**< Connection security level. */ +} ble_gap_evt_conn_sec_update_t; + + +/** @brief Event data for timeout event. */ +typedef struct +{ + uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */ +} ble_gap_evt_timeout_t; + + +/** @brief Event data for advertisement report event. */ +typedef struct +{ + int8_t rssi; /**< Received Signal Strength Indication in dBm. */ +} ble_gap_evt_rssi_changed_t; + + + +/**@brief GAP event callback event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which event occured. */ + union /**< union alternative identified by evt_id in enclosing struct. */ + { + ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */ + ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */ + ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */ + ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */ + ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */ + ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */ + ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */ + ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */ + ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */ + ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */ + ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event parameters. */ + } params; + +} ble_gap_evt_t; + + +/**@brief Set local Bluetooth address. + * + * @param[in] p_addr Pointer to address structure. + * + * @return @ref NRF_SUCCESS Address successfully set. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address. + * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry. + */ +SVCALL(SD_BLE_GAP_ADDRESS_SET, uint32_t, sd_ble_gap_address_set(ble_gap_addr_t const * const p_addr)); + + +/**@brief Get local Bluetooth address. + * + * @param[out] p_addr Pointer to address structure. + * + * @return @ref NRF_SUCCESS Address successfully retrieved. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GAP_ADDRESS_GET, uint32_t, sd_ble_gap_address_get(ble_gap_addr_t * const p_addr)); + + +/**@brief Set, clear or update advertisement and scan response data. + * + * @note The format of the advertisement data will be checked by this call to ensure interoperability. + * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and + * duplicating the local name in the advertisement data and scan response data. + * + * @note: To clear the advertisement data and set it to a 0-length packet, simply provide a valid pointer (p_data/p_sr_data) with its corresponding + * length (dlen/srdlen) set to 0. + * + * @note: The call will fail if p_data and p_sr_data are both NULL since this would have no effect. + * + * @param[in] p_data Raw data to be placed in advertisement packet. If NULL, no changes are made to the current advertisement packet data. + * @param[in] dlen Data length for p_data. Max size: @ref BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_data is NULL, can be 0 if p_data is not NULL. + * @param[in] p_sr_data Raw data to be placed in scan response packet. If NULL, no changes are made to the current scan response packet data. + * @param[in] srdlen Data length for p_sr_data. Max size: @ref BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_sr_data is NULL, can be 0 if p_data is not NULL. + * + * @return @ref NRF_SUCCESS Advertisement data successfully updated or cleared. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied. + * @return @ref NRF_ERROR_INVALID_DATA Invalid data type(s) supplied, check the advertising data format specification. + * @return @ref NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied. + * @return @ref BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied. + * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry. + */ +SVCALL(SD_BLE_GAP_ADV_DATA_SET, uint32_t, sd_ble_gap_adv_data_set(uint8_t const * const p_data, uint8_t dlen, uint8_t const * const p_sr_data, uint8_t srdlen)); + + +/**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). + * + * @param[in] p_adv_params Pointer to advertising parameters structure. + * + * @return @ref NRF_SUCCESS The BLE stack has started advertising. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check the accepted ranges and limits. + * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Bluetooth address supplied. + * @return @ref BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible. + */ +SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(ble_gap_adv_params_t const * const p_adv_params)); + + +/**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). + * + * @return @ref NRF_SUCCESS The BLE stack has stopped advertising. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation (most probably not in advertising state). + */ +SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(void)); + + +/**@brief Update connection parameters. + * + * @details In the central role this will initiate a Link Layer connection parameter update procedure, + * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for + * the central to perform the procedure. In both cases, and regardless of success or failure, the application + * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event. + * + * @note If both a connection supervision timeout and a maximum connection interval are specified, then the following constraint + * applies: (conn_sup_timeout * 8) >= (max_conn_interval * (slave_latency + 1)) + * + * @param[in] conn_handle Connection handle. + * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role, + * the parameters in the PPCP characteristic of the GAP service will be used instead. + * + * @return @ref NRF_SUCCESS The Connection Update procedure has been started successfully. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. + * @return @ref NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, process pending events and retry. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GAP_CONN_PARAM_UPDATE, uint32_t, sd_ble_gap_conn_param_update(uint16_t conn_handle, ble_gap_conn_params_t const * const p_conn_params)); + + +/**@brief Disconnect (GAP Link Termination). + * + * @details This call initiates the disconnection procedure, and its completion will be communicated to the application + * with a BLE_GAP_EVT_DISCONNECTED event. + * + * @param[in] conn_handle Connection handle. + * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are BTLE_REMOTE_USER_TERMINATED_CONNECTION and BTLE_CONN_INTERVAL_UNACCEPTABLE). + * + * @return @ref NRF_SUCCESS The disconnection procedure has been started successfully. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation (disconnection is already in progress or not connected at all). + */ +SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code)); + + +/**@brief Set the radio's transmit power. + * + * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm). + * + * @note -40 dBm will not actually give -40 dBm, but will instead be remapped to -30 dBm. + * + * @return @ref NRF_SUCCESS Successfully changed the transmit power. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry. + */ +SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(int8_t tx_power)); + + +/**@brief Set GAP Appearance value. + * + * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES. + * + * @return @ref NRF_SUCCESS Appearance value set successfully. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + */ +SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance)); + + +/**@brief Get GAP Appearance value. + * + * @param[out] p_appearance Appearance (16-bit), see @ref BLE_APPEARANCES. + * + * @return @ref NRF_SUCCESS Appearance value retrieved successfully. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t * const p_appearance)); + + +/**@brief Set GAP Peripheral Preferred Connection Parameters. + * + * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters. + * + * @return @ref NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + */ +SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const * const p_conn_params)); + + +/**@brief Get GAP Peripheral Preferred Connection Parameters. + * + * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored. + * + * @return @ref NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + */ +SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t * const p_conn_params)); + + +/**@brief Set GAP device name. + * + * @param[in] p_write_perm Write permissions for the Device Name characteristic see @ref ble_gap_conn_sec_mode_t. + * @param[in] p_dev_name Pointer to a UTF-8 encoded, non NULL-terminated string. + * @param[in] len Length of the UTF-8, non NULL-terminated string pointed to by p_dev_name in octets (must be smaller or equal than @ref BLE_GAP_DEVNAME_MAX_LEN). + * + * @return @ref NRF_SUCCESS GAP device name and permissions set successfully. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + */ +SVCALL(SD_BLE_GAP_DEVICE_NAME_SET, uint32_t, sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const * const p_write_perm, uint8_t const * const p_dev_name, uint16_t len)); + + +/**@brief Get GAP device name. + * + * @param[in] p_dev_name Pointer to an empty buffer where the UTF-8 non NULL-terminated string will be placed. Set to NULL to obtain the complete device name length. + * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output. + * + * @note If the device name is longer than the size of the supplied buffer, + * p_len will return the complete device name length, + * and not the number of bytes actually returned in p_dev_name. + * The application may use this information to allocate a suitable buffer size. + * + * @return @ref NRF_SUCCESS GAP device name retrieved successfully. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + */ +SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t * const p_dev_name, uint16_t * const p_len)); + + +/**@brief Initiate GAP Authentication procedure. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_sec_params Pointer to the @ref ble_gap_sec_params_t structure with the security parameters to be used during the pairing procedure. + * + * @details In the central role, this function will send an SMP Pairing Request, otherwise in the peripheral role, an SMP Security Request will be sent. + * In the peripheral role, only the timeout, bond and mitm fields of @ref ble_gap_sec_params_t are used. + * + * @note The GAP Authentication procedure may be triggered by the central without calling this function when accessing a secure service. + * @note Calling this function may result in the following events depending on the outcome and parameters: @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST, + * @ref BLE_GAP_EVT_SEC_INFO_REQUEST, @ref BLE_GAP_EVT_AUTH_KEY_REQUEST, @ref BLE_GAP_EVT_AUTH_STATUS. + * @note The timeout parameter in @ref ble_gap_sec_params_t is interpreted here as the Security Request timeout + * + * + * @return @ref NRF_SUCCESS Successfully initiated authentication procedure. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const * const p_sec_params)); + + +/**@brief Reply with GAP security parameters. + * + * @param[in] conn_handle Connection handle. + * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS. + * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST, calling it at other times will result in an NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * @note The timeout parameter in @ref ble_gap_sec_params_t is interpreted here as the SMP procedure timeout, and must be 30 seconds. The function will fail + * if the application supplies a different value. + * + * @return @ref NRF_SUCCESS Successfully accepted security parameter from the application. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_SEC_PARAMS_REPLY, uint32_t, sd_ble_gap_sec_params_reply(uint16_t conn_handle, uint8_t sec_status, ble_gap_sec_params_t const * const p_sec_params)); + + +/**@brief Reply with an authentication key. + * + * @param[in] conn_handle Connection handle. + * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES. + * @param[in] key If key type is BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL. + * If key type is BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination). + * If key type is BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in Little Endian format. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_AUTH_KEY_REQUEST, calling it at other times will result in an NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * + * @return @ref NRF_SUCCESS Authentication key successfully set. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t conn_handle, uint8_t key_type, uint8_t const * const key)); + + +/**@brief Reply with GAP security information. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure. May be NULL to signal none is available. + * @param[in] p_sign_info Pointer to a @ref ble_gap_sign_info_t signing information structure. May be NULL to signal none is available. + * + * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_INFO_REQUEST, calling it at other times will result in NRF_ERROR_INVALID_STATE. + * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. + * @note Data signing is not implemented yet. p_sign_info must therefore be NULL. + * + * @return @ref NRF_SUCCESS Successfully accepted security information. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry. + */ +SVCALL(SD_BLE_GAP_SEC_INFO_REPLY, uint32_t, sd_ble_gap_sec_info_reply(uint16_t conn_handle, ble_gap_enc_info_t const * const p_enc_info, ble_gap_sign_info_t const * const p_sign_info)); + + +/**@brief Get the current connection security. + * + * @param[in] conn_handle Connection handle. + * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in. + * + * @return @ref NRF_SUCCESS Current connection security successfully retrieved. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_CONN_SEC_GET, uint32_t, sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t * const p_conn_sec)); + + +/**@brief Start reporting the received signal strength to the application. + * + * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called. + * + * @param[in] conn_handle Connection handle. + * + * @return @ref NRF_SUCCESS Successfully activated RSSI reporting. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle)); + + +/**@brief Stop reporting the received singnal strength. + * + * An RSSI change detected before the call but not yet received by the application + * may be reported after @ref sd_ble_gap_rssi_stop has been called. + * + * @param[in] conn_handle Connection handle. + * + * @return @ref NRF_SUCCESS Successfully deactivated RSSI reporting. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. + */ +SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle)); + +#endif // BLE_GAP_H__ + +/** + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gatt.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gatt.h new file mode 100644 index 0000000000..8a64b520b5 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gatt.h @@ -0,0 +1,167 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ + /** + @addtogroup BLE_GATT Generic Attribute Profile (GATT) Common + @{ + @brief Common definitions and prototypes for the GATT interfaces. + */ + +#ifndef BLE_GATT_H__ +#define BLE_GATT_H__ + +#include "nordic_global.h" +#include "ble_types.h" +#include "ble_ranges.h" + + +/** @addtogroup BLE_GATT_DEFINES Defines + * @{ */ + +/** @brief Default MTU size. */ +#define GATT_MTU_SIZE_DEFAULT 23 + +/** @brief Only the default MTU size of 23 is currently supported. */ +#define GATT_RX_MTU 23 + + +/**@brief Invalid Attribute Handle. */ +#define BLE_GATT_HANDLE_INVALID 0x0000 + +/** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources + * @{ */ +#define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */ +/** @} */ + +/** @defgroup BLE_GATT_WRITE_OPS GATT Write operations + * @{ */ +#define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */ +#define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */ +#define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */ +#define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */ +#define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */ +/** @} */ + +/** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags + * @{ */ +#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00 +#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01 +/** @} */ + +/** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations + * @{ */ +#define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */ +#define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */ +/** @} */ + +/** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes + * @{ */ +#define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */ +#define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */ +#define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */ +#define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */ +#define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */ +#define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorisation. */ +#define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */ +#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */ +#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */ +#define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */ +#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */ +#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */ +#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */ +#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */ +#define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */ +#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */ +#define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */ +#define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */ +#define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */ +/** @} */ + + +/** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats + * @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml + * @{ */ +#define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */ +#define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */ +#define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */ +#define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */ +#define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */ +#define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */ +#define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */ +#define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */ +#define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */ +#define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */ +#define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */ +#define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */ +#define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */ +#define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */ +/** @} */ + +/** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces + * @{ + */ +#define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01 +#define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000 +/** @} */ + +/** @} */ + +/**@brief GATT Characteristic Properties. */ +typedef struct +{ + /* Standard properties */ + uint8_t broadcast :1; /**< Broadcasting of value permitted. */ + uint8_t read :1; /**< Reading value permitted. */ + uint8_t write_wo_resp :1; /**< Writing value with Write Command permitted. */ + uint8_t write :1; /**< Writing value with Write Request permitted. */ + uint8_t notify :1; /**< Notications of value permitted. */ + uint8_t indicate :1; /**< Indications of value permitted. */ + uint8_t auth_signed_wr :1; /**< Writing value with Signed Write Command permitted. */ +} ble_gatt_char_props_t; + +/**@brief GATT Characteristic Extended Properties. */ +typedef struct +{ + /* Extended properties */ + uint8_t reliable_wr :1; /**< Writing value with Queued Write Request permitted. */ + uint8_t wr_aux :1; /**< Writing the Characteristic User Description permitted. */ +} ble_gatt_char_ext_props_t; + +#endif // BLE_GATT_H__ + +/** + @} + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gattc.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gattc.h new file mode 100644 index 0000000000..9a49031df7 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gattc.h @@ -0,0 +1,396 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ +/** + @addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client + @{ + @brief Definitions and prototypes for the GATT Client interface. + */ + +#ifndef BLE_GATTC_H__ +#define BLE_GATTC_H__ + +#include "nordic_global.h" +#include "ble_gatt.h" +#include "ble_types.h" +#include "ble_ranges.h" +#include "nrf_svc.h" + + +/**@brief GATTC API SVC numbers. */ +enum BLE_GATTC_SVCS +{ + SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */ + SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */ + SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */ + SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */ + SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */ + SD_BLE_GATTC_READ, /**< Generic read. */ + SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */ + SD_BLE_GATTC_WRITE, /**< Generic write. */ + SD_BLE_GATTC_HV_CONFIRM /**< Handle Value Confirmation. */ +}; + +/** @addtogroup BLE_GATTC_DEFINES Defines + * @{ */ + +/** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC + * @{ */ +#define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000) +/** @} */ + +/**@brief Last Attribute Handle. */ +#define BLE_GATTC_HANDLE_END 0xFFFF + +/** @} */ + +/**@brief Operation Handle Range. */ +typedef struct +{ + uint16_t start_handle; /**< Start Handle. */ + uint16_t end_handle; /**< End Handle. */ +} ble_gattc_handle_range_t; + + +/**@brief GATT service. */ +typedef struct +{ + ble_uuid_t uuid; /**< Service UUID. */ + ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */ +} ble_gattc_service_t; + + +/**@brief GATT include. */ +typedef struct +{ + uint16_t handle; /**< Include Handle. */ + ble_gattc_service_t included_srvc; /**< Handle of the included service. */ +} ble_gattc_include_t; + + +/**@brief GATT characteristic. */ +typedef struct +{ + ble_uuid_t uuid; /**< Characteristic UUID. */ + ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ + uint8_t char_ext_props : 1; /**< Extended properties present. */ + uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */ + uint16_t handle_value; /**< Handle of the Characteristic Value. */ +} ble_gattc_char_t; + + +/**@brief GATT descriptor. */ +typedef struct +{ + uint16_t handle; /**< Descriptor Handle. */ + ble_uuid_t uuid; /**< Descriptor UUID. */ +} ble_gattc_desc_t; + + +/**@brief Write Parameters. */ +typedef struct +{ + uint8_t write_op; /**< Write Operation to be performed, see BLE_GATT_WRITE_OPS. */ + uint16_t handle; /**< Handle to the attribute to be written. */ + uint16_t offset; /**< Offset in bytes. */ + uint16_t len; /**< Length of data in bytes. */ + uint8_t* p_value; /**< Pointer to the value data. */ + uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */ +} ble_gattc_write_params_t; + + +/** + * @brief GATT Client Event IDs. + */ +enum BLE_GATTC_EVTS +{ + BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. */ + BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. */ + BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. */ + BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. */ + BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. */ + BLE_GATTC_EVT_READ_RSP, /**< Read Response event. */ + BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. */ + BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. */ + BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. */ + BLE_GATTC_EVT_TIMEOUT /**< Timeout event. */ +}; + +/**@brief Event structure for BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Service count. */ + ble_gattc_service_t services[1]; /**< Service data, variable length. */ +} ble_gattc_evt_prim_srvc_disc_rsp_t; + +/**@brief Event structure for BLE_GATTC_EVT_REL_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Include count. */ + ble_gattc_include_t includes[1]; /**< Include data, variable length. */ +} ble_gattc_evt_rel_disc_rsp_t; + +/**@brief Event structure for BLE_GATTC_EVT_CHAR_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Characteristic count. */ + ble_gattc_char_t chars[1]; /**< Characteristic data, variable length. */ +} ble_gattc_evt_char_disc_rsp_t; + +/**@brief Event structure for BLE_GATTC_EVT_DESC_DISC_RSP. */ +typedef struct +{ + uint16_t count; /**< Descriptor count. */ + ble_gattc_desc_t descs[1]; /**< Descriptor data, variable length. */ +} ble_gattc_evt_desc_disc_rsp_t; + +/**@brief GATT read by UUID handle value pair. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint8_t *p_value; /**< Pointer to value, variable length (length available as value_len in ble_gattc_evt_read_by_uuid_rsp_t). + Please note that this pointer is absolute to the memory provided by the user when retrieving the event, + so it will effectively point to a location inside the handle_value array. */ +} ble_gattc_handle_value_t; + +/**@brief Event structure for BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */ +typedef struct +{ + uint16_t count; /**< Handle-Value Pair Count. */ + uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */ + ble_gattc_handle_value_t handle_value[1]; /**< Handle-Value(s) list, variable length. */ +} ble_gattc_evt_char_val_by_uuid_read_rsp_t; + +/**@brief Event structure for BLE_GATTC_EVT_READ_RSP. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint16_t offset; /**< Offset of the attribute data. */ + uint16_t len; /**< Attribute data length. */ + uint8_t data[1]; /**< Attribute data, variable length. */ +} ble_gattc_evt_read_rsp_t; + +/**@brief Event structure for BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */ +typedef struct +{ + uint16_t len; /**< Concatenated Attribute values length. */ + uint8_t values[1]; /**< Attribute values, variable length. */ +} ble_gattc_evt_char_vals_read_rsp_t; + +/**@brief Event structure for BLE_GATTC_EVT_WRITE_RSP. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */ + uint16_t offset; /**< Data Offset. */ + uint16_t len; /**< Data length. */ + uint8_t data[1]; /**< Data, variable length. */ +} ble_gattc_evt_write_rsp_t; + +/**@brief Event structure for BLE_GATTC_EVT_HVX. */ +typedef struct +{ + uint16_t handle; /**< Handle to which the HVx operation applies. */ + uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ + uint16_t len; /**< Attribute data length. */ + uint8_t data[1]; /**< Attribute data, variable length. */ +} ble_gattc_evt_hvx_t; + +/**@brief Event structure for BLE_GATTC_EVT_TIMEOUT. */ +typedef struct +{ + uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ +} ble_gattc_evt_timeout_t; + +/**@brief GATTC event type. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which event occured. */ + uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ + uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases BLE_GATT_HANDLE_INVALID. */ + union + { + ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */ + ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */ + ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */ + ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */ + ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */ + ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */ + ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */ + ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */ + ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */ + ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */ + } params; /**< Event Parameters. @note Only valid if @ref gatt_status == BLE_GATT_STATUS_SUCCESS. */ +} ble_gattc_evt_t; + + +/**@brief Initiate or continue a GATT Primary Service Discovery procedure. + * + * @details This function initiates a Primary Service discovery, starting from the supplied handle. + * If the last service has not been reached, this must be called again with an updated start handle value to continue the search. + * + * @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with + * type BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] start_handle Handle to start searching from. + * @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned. + * + * @return @ref NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_BUSY Client procedure already in progress. + */ +SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const * const p_srvc_uuid)); + + +/**@brief Initiate or continue a GATT Relationship Discovery procedure. + * + * @details This function initiates the Find Included Services sub-procedure. If the last included service has not been reached, + * this must be called again with an updated handle range to continue the search. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on. + * + * @return @ref NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_BUSY Client procedure already in progress. + */ +SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range)); + + +/**@brief Initiate or continue a GATT Characteristic Discovery procedure. + * + * @details This function initiates a Characteristic discovery procedure. If the last Characteristic has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * + * @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with + * type BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on. + * + * @return @ref NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_BUSY Client procedure already in progress. + */ +SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range)); + + +/**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure. + * + * @details This function initiates the Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on. + * + * @return @ref NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_BUSY Client procedure already in progress. + */ +SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range)); + + +/**@brief Initiate or continue a GATT Read using Characteristic UUID procedure. + * + * @details This function initiates the Read using Characteristic UUID procedure. If the last Characteristic has not been reached, + * this must be called again with an updated handle range to continue the discovery. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_uuid Pointer to a Characteristic value UUID to read. + * @param[in] p_handle_range A pointer to the range of handles to perform this procedure on. + * + * @return @ref NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_BUSY Client procedure already in progress. + */ +SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const * const p_uuid, ble_gattc_handle_range_t const * const p_handle_range)); + + +/**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure. + * + * @details This function initiates a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor + * to be read is longer than GATT_MTU - 1, this function must be called multiple times with appropriate offset to read the + * complete value. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] handle The handle of the attribute to be read. + * @param[in] offset Offset into the attribute value to be read. + * + * @return @ref NRF_SUCCESS Successfully started or resumed the Read (Long) procedure. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_BUSY Client procedure already in progress. + */ +SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset)); + + +/**@brief Initiate a GATT Read Multiple Characteristic Values procedure. + * + * @details This function initiates a GATT Read Multiple Characteristic Values procedure. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read. + * @param[in] handle_count The number of handles in p_handles. + * + * @return @ref NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_BUSY Client procedure already in progress. + */ +SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const * const p_handles, uint16_t handle_count)); + + +/**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure. + * + * @details This function can perform all write procedures described in GATT. + * + * @note It is important to note that a write without response will consume an application buffer, and will therefore + * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. A write on the other hand will use the + * standard client internal buffer and thus will only generate a @ref BLE_GATTC_EVT_WRITE_RSP event as soon as the write response + * has been received from the peer. Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] p_write_params A pointer to a write parameters structure. + * + * @return @ref NRF_SUCCESS Successfully started the Write procedure. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + * @return @ref NRF_ERROR_BUSY Procedure already in progress. + * @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers left. + */ +SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const * const p_write_params)); + + +/**@brief Send a Handle Value Confirmation to the GATT Server. + * + * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on. + * @param[in] handle The handle of the attribute in the indication. + * + * @return @ref NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_STATE No Indication pending to be confirmed. + * @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle. + * @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers left. + */ +SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle)); + + +#endif /* BLE_GATTC_H__ */ + +/** + @} + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gatts.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gatts.h new file mode 100644 index 0000000000..8b54d750b7 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_gatts.h @@ -0,0 +1,548 @@ +/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ +/** + @addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server + @{ + @brief Definitions and prototypes for the GATTS interface. + */ + +#ifndef BLE_GATTS_H__ +#define BLE_GATTS_H__ + +#include "nordic_global.h" +#include "ble_types.h" +#include "ble_ranges.h" +#include "ble_l2cap.h" +#include "ble_gap.h" +#include "ble_gatt.h" +#include "nrf_svc.h" + + +/** + * @brief GATTS API SVC numbers. + */ +enum BLE_GATTS_SVCS +{ + SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */ + SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */ + SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */ + SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */ + SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */ + SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */ + SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */ + SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */ + SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */ + SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */ + SD_BLE_GATTS_SYS_ATTR_GET, /**< Get updated persistent system attributes after terminating a connection. */ +}; + + +/** @addtogroup BLE_GATTS_DEFINES Defines + * @{ */ + +/** @brief Only the default MTU size of 23 is currently supported. */ +#define GATT_RX_MTU 23 + +/** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS + * @{ */ +#define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */ +#define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */ +/** @} */ + +/** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths + * @{ */ +#define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */ +#define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */ +/** @} */ + +/** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types + * @{ */ +#define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */ +#define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */ +#define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */ +/** @} */ + + +/** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types + * @{ */ +#define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */ +#define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */ +#define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */ +#define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */ +#define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */ +#define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */ +#define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */ +#define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */ +/** @} */ + + +/** @defgroup BLE_GATTS_OPS GATT Server Operations + * @{ */ +#define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */ +#define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */ +#define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */ +#define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */ +#define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */ +#define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */ +#define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */ +/** @} */ + +/** @defgroup BLE_GATTS_VLOCS GATT Value Locations + * @{ */ +#define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */ +#define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */ +#define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack + will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */ +/** @} */ + +/** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types + * @{ */ +#define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */ +#define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */ +#define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */ +/** @} */ + + +/** @} */ + +/**@brief Attribute metadata. */ +typedef struct +{ + ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */ + ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ + uint8_t vlen :1; /**< Variable length attribute. */ + uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/ + uint8_t rd_auth :1; /**< Read Authorization and value will be requested from the application on every read operation. */ + uint8_t wr_auth :1; /**< Write Authorization will be requested from the application on every Write Request operation (but not Write Command). */ +} ble_gatts_attr_md_t; + + +/**@brief GATT Attribute. */ +typedef struct +{ + ble_uuid_t* p_uuid; /**< Pointer to the attribute UUID. */ + ble_gatts_attr_md_t* p_attr_md; /**< Pointer to the attribute metadata structure. */ + uint16_t init_len; /**< Initial attribute value length in bytes. */ + uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */ + uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */ + uint8_t* p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer + that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location. + The stack may access that memory directly without the application's knowledge. */ +} ble_gatts_attr_t; + + +/**@brief GATT Attribute Context. */ +typedef struct +{ + ble_uuid_t srvc_uuid; /**< Service UUID. */ + ble_uuid_t char_uuid; /**< Characteristic UUID if applicable (BLE_UUID_TYPE_UNKNOWN if N/A). */ + ble_uuid_t desc_uuid; /**< Descriptor UUID if applicable (BLE_UUID_TYPE_UNKNOWN if N/A). */ + uint16_t srvc_handle; /**< Service Handle. */ + uint16_t value_handle; /**< Characteristic Handle if applicable (BLE_GATT_HANDLE_INVALID if N/A). */ + uint8_t type; /**< Attribute Type, see @ref BLE_GATTS_ATTR_TYPES. */ +} ble_gatts_attr_context_t; + + +/**@brief GATT Characteristic Presentation Format. */ +typedef struct +{ + uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */ + int8_t exponent; /**< Exponent for integer data types. */ + uint16_t unit; /**< UUID from Bluetooth Assigned Numbers. */ + uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ + uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ +} ble_gatts_char_pf_t; + + +/**@brief GATT Characteristic metadata. */ +typedef struct +{ + ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ + ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */ + uint8_t* p_char_user_desc; /**< Pointer to a UTF-8, NULL if the descriptor is not required. */ + uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */ + uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */ + ble_gatts_char_pf_t* p_char_pf; /**< Pointer to a presentation format structure or NULL if the descriptor is not required. */ + ble_gatts_attr_md_t* p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */ + ble_gatts_attr_md_t* p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */ + ble_gatts_attr_md_t* p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */ +} ble_gatts_char_md_t; + + +/**@brief GATT Characteristic Definition Handles. */ +typedef struct +{ + uint16_t value_handle; /**< Handle to the characteristic value. */ + uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or BLE_GATT_HANDLE_INVALID if not present. */ + uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or BLE_GATT_HANDLE_INVALID if not present. */ + uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or BLE_GATT_HANDLE_INVALID if not present. */ +} ble_gatts_char_handles_t; + + +/**@brief GATT HVx parameters. */ +typedef struct +{ + uint16_t handle; /**< Characteristic Value Handle. */ + uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ + uint16_t offset; /**< Offset within the attribute value. */ + uint16_t* p_len; /**< Length in bytes to be written, length in bytes written after successful return. */ + uint8_t* p_data; /**< Actual data content, use NULL to use the current attribute value. */ +} ble_gatts_hvx_params_t; + +/**@brief GATT Read Authorization parameters. */ +typedef struct +{ + uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ + uint8_t update : 1; /**< If set, data supplied in p_data will be used in the ATT response. */ + uint16_t offset; /**< Offset of the attribute value being updated. */ + uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */ + uint8_t* p_data; /**< Pointer to new value used to update the attribute value. */ +} ble_gatts_read_authorize_params_t; + +/**@brief GATT Write Authorisation parameters. */ +typedef struct +{ + uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ +} ble_gatts_write_authorize_params_t; + +/**@brief GATT Read or Write Authorize Reply parameters. */ +typedef struct +{ + uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ + union { + ble_gatts_read_authorize_params_t read; /**< Read authorization parameters. */ + ble_gatts_write_authorize_params_t write; /**< Write authorization parameters. */ + } params; +} ble_gatts_rw_authorize_reply_params_t; + + +/** + * @brief GATT Server Event IDs. + */ +enum BLE_GATTS_EVTS +{ + BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. */ + BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. */ + BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending, awaiting a sd_ble_gatts_sys_attr_set(). */ + BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. */ + BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. */ + BLE_GATTS_EVT_TIMEOUT /**< Timeout. */ +}; + + +/**@brief Event structure for BLE_GATTS_EVT_WRITE. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */ + ble_gatts_attr_context_t context; /**< Attribute Context. */ + uint16_t offset; /**< Offset for the write operation. */ + uint16_t len; /**< Length of the incoming data. */ + uint8_t data[1]; /**< Incoming data, variable length. */ +} ble_gatts_evt_write_t; + +/**@brief Event structure for authorize read request. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ + ble_gatts_attr_context_t context; /**< Attribute Context. */ + uint16_t offset; /**< Offset for the read operation. */ +} ble_gatts_evt_read_t; + +/**@brief Event structure for BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */ +typedef struct +{ + uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ + union { + ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */ + ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */ + } request; +} ble_gatts_evt_rw_authorize_request_t; + +/**@brief Event structure for BLE_GATTS_EVT_SYS_ATTR_MISSING. */ +typedef struct +{ + uint8_t hint; +} ble_gatts_evt_sys_attr_missing_t; + + +/**@brief Event structure for BLE_GATTS_EVT_HVC. */ +typedef struct +{ + uint16_t handle; /**< Attribute Handle. */ +} ble_gatts_evt_hvc_t; + +/**@brief Event structure for BLE_GATTS_EVT_TIMEOUT. */ +typedef struct +{ + uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ +} ble_gatts_evt_timeout_t; + + +/**@brief GATT Server event callback event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which event occurred. */ + union + { + ble_gatts_evt_write_t write; /**< Write Event Parameters. */ + ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */ + ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */ + ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */ + ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */ + } params; +} ble_gatts_evt_t; + + +/**@brief Add a service declaration to the local server ATT table. + * + * @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES. + * @param[in] p_uuid Pointer to service UUID. + * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to + * add a secondary service declaration that is not referenced by another service later in the ATT table. + * + * @return @ref NRF_SUCCESS Successfully added a service declaration. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table. + * @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const*const p_uuid, uint16_t *const p_handle)); + + +/**@brief Add an include declaration to the local server ATT table. + * + * @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential addition is supported at this time). + * + * @note The included service must already be present in the ATT table prior to this call. + * + * @param[in] service_handle Handle of the service where the included service is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] inc_srvc_handle Handle of the included service. + * @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @return @ref NRF_SUCCESS Successfully added an include declaration. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. + * @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed. + * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @return @ref NRF_ERROR_NOT_FOUND Attribute not found. + */ +SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *const p_include_handle)); + + +/**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the local server ATT table. + * + * @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential addition is supported at this time). + * + * @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writeable auxiliaries bits, + * readable (no security) and writeable (selectable) CCCDs and SCCDs and valid presentation format values. + * + * @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions. + * + * @param[in] service_handle Handle of the service where the characteristic is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] p_char_md Characteristic metadata. + * @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value. + * @param[out] p_handles Pointer to the structure where the assigned handles will be stored. + * + * @return @ref NRF_SUCCESS Successfully added a characteristic. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required. + * @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + */ +SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const*const p_char_md, ble_gatts_attr_t const*const p_attr_char_value, ble_gatts_char_handles_t *const p_handles)); + + +/**@brief Add a descriptor to the local server ATT table. + * + * @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential addition is supported at this time). + * + * @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. + * @param[in] p_attr Pointer to the attribute structure. + * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. + * + * @return @ref NRF_SUCCESS Successfully added a descriptor. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required. + * @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. + * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + */ +SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const * const p_attr, uint16_t* const p_handle)); + +/**@brief Set the value of a given attribute. + * + * @param[in] handle Attribute handle. + * @param[in] offset Offset in bytes to write from. + * @param[in,out] p_len Length in bytes to be written, length in bytes written after successful return. + * @param[in] p_value Pointer to a buffer (at least len bytes long) containing the desired attribute value. + * + * @return @ref NRF_SUCCESS Successfully set the value of the attribute. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_NOT_FOUND Attribute not found. + * @return @ref NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application. + * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. + */ +SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t handle, uint16_t offset, uint16_t* const p_len, uint8_t const * const p_value)); + +/**@brief Get the value of a given attribute. + * + * @param[in] handle Attribute handle. + * @param[in] offset Offset in bytes to read from. + * @param[in,out] p_len Length in bytes to be read, total length of attribute value (in bytes, starting from offset) after successful return. + * @param[in,out] p_data Pointer to a buffer (at least len bytes long) where to store the attribute value. Set to NULL to obtain the complete length of attribute value. + * + * @note If the attribute value is longer than the size of the supplied buffer, + * p_len will return the total attribute value length (excluding offset), + * and not the number of bytes actually returned in p_data. + * The application may use this information to allocate a suitable buffer size. + * + * @return @ref NRF_SUCCESS Successfully retrieved the value of the attribute. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_NOT_FOUND Attribute not found. + */ +SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t handle, uint16_t offset, uint16_t *const p_len, uint8_t* const p_data)); + +/**@brief Notify or Indicate an attribute value. + * + * @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation + * (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that + * the application can atomically perform a value update and a server initiated transaction with a single API call. + * If the application chooses to indicate an attribute value, a @ref BLE_GATTS_EVT_HVC will be sent up as soon as the confirmation arrives from + * the peer. + * + * @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution. + * When receiveing the error codes @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and + * @ref BLE_ERROR_NO_TX_BUFFERS the ATT table has been updated. + * The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len). + * + * @note It is important to note that a notification will consume an application buffer, and will therefore + * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. An indication on the other hand will use the + * standard server internal buffer and thus will only generate a @ref BLE_GATTS_EVT_HVC event as soon as the confirmation + * has been received from the peer. Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_hvx_params Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with + * the contents pointed by it before sending the notification or indication. + * + * @return @ref NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate. + * @return @ref BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated. + * @return @ref NRF_ERROR_NOT_FOUND Attribute not found. + * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, notifications or indications must be enabled in the CCCD. + * @return @ref NRF_ERROR_BUSY Procedure already in progress. + * @return @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + * @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers to send the data, applies only to notifications. + */ +SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const*const p_hvx_params)); + +/**@brief Indicate the Service Changed attribute value. + * + * @details This call will send a Handle Value Indication to one or more peers connected to inform them that the attribute + * table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will + * be issued. + * + * @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here. + * + * @param[in] conn_handle Connection handle. + * @param[in] start_handle Start of affected attribute handle range. + * @param[in] end_handle End of affected attribute handle range. + * + * @return @ref NRF_SUCCESS Successfully queued the Service Changed indication for transmission. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application. + * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, notifications or indications must be enabled in the CCCD. + * @return @ref NRF_ERROR_BUSY Procedure already in progress. + * @return @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. + */ +SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)); + +/**@brief Respond to a Read/Write authorization request. + * + * @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application. + * + * @return @ref NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, ATT table updated. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_STATE No authorization request pending. + * @return @ref NRF_ERROR_INVALID_PARAM Authorization op invalid, + * or for Read Authorization reply: requested handles not replied with, + * or for Write Authorization reply: handle supplied does not match requested handle. + */ +SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const*const p_rw_authorize_reply_params)); + + +/**@brief Update persistent system attribute information. + * + * @details Supply to the stack information about persistent system attributes. + * This call is legal in the connected state only, and is usually + * made immediately after a connection is established and the bond identified. + * usually as a response to a BLE_GATTS_EVT_SYS_ATTR_MISSING. + * + * p_sysattrs may point directly to the application's stored copy of the struct. + * If the pointer is NULL, the system attribute info is initialized, assuming that + * the application does not have any previously saved data for this bond. + * + * @note The state of persistent system attributes is reset upon connection and then remembered for its duration. + * + * @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially. + * This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or + * reset the SoftDevice to return to a known state. + * + * @param[in] conn_handle Connection handle. + * @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL. + * @param[in] len Size of data pointed by p_sys_attr_data, in octets. + * + * @return @ref NRF_SUCCESS Successfully set the system attribute information. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get. + * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const*const p_sys_attr_data, uint16_t len)); + + +/**@brief Retrieve persistent system attribute information from the stack. + * + * @details This call is used to retrieve information about values to be stored perisistently by the application + * after a connection has been terminated. When a new connection is made to the same bond, the values + * should be restored using @ref sd_ble_gatts_sys_attr_set. + * The data should be read before any new advertising is started, or any new connection established. The connection handle for + * the previous now defunct connection will remain valid until a new one is created to allow this API call to refer to it. + * + * @param[in] conn_handle Connection handle of the recently terminated connection. + * @param[in] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. NULL can be provided to + * obtain the length of the data + * @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditially updated to actual length of system attribute data. + * + * @return @ref NRF_SUCCESS Successfully retrieved the system attribute information. + * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer. + */ +SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t * const p_sys_attr_data, uint16_t* const p_len)); + + +#endif // BLE_GATTS_H__ + +/** + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_hci.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_hci.h new file mode 100644 index 0000000000..925776bd7d --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_hci.h @@ -0,0 +1,96 @@ +/* + Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + + The information contained herein is confidential property of Nordic Semiconductor. The use, + copying, transfer or disclosure of such information is prohibited except by express written + agreement with Nordic Semiconductor. + */ +/** + @addtogroup BLE_COMMON + @{ +*/ + + +#ifndef BLE_HCI_H__ +#define BLE_HCI_H__ + +/** @defgroup BLE_HCI_STATUS_CODES Bluetooth status codes + * @{ */ + +#define BLE_HCI_STATUS_CODE_SUCCESS 0x00 +#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01 +#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02 +/*0x03 Hardware Failure +0x04 Page Timeout +*/ +#define BLE_HCI_AUTHENTICATION_FAILURE 0x05 +#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06 +#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07 +#define BLE_HCI_CONNECTION_TIMEOUT 0x08 +/*0x09 Connection Limit Exceeded +0x0A Synchronous Connection Limit To A Device Exceeded +0x0B ACL Connection Already Exists*/ +#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C +/*0x0D Connection Rejected due to Limited Resources +0x0E Connection Rejected Due To Security Reasons +0x0F Connection Rejected due to Unacceptable BD_ADDR +0x10 Connection Accept Timeout Exceeded +0x11 Unsupported Feature or Parameter Value*/ +#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12 +#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 +#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14 +#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15 +#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16 +/* +0x17 Repeated Attempts +0x18 Pairing Not Allowed +0x19 Unknown LMP PDU +*/ +#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A +/* +0x1B SCO Offset Rejected +0x1C SCO Interval Rejected +0x1D SCO Air Mode Rejected*/ +#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E +#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F +/*0x20 Unsupported LMP Parameter Value +0x21 Role Change Not Allowed +*/ +#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22 +/*0x23 LMP Error Transaction Collision*/ +#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24 +/*0x25 Encryption Mode Not Acceptable +0x26 Link Key Can Not be Changed +0x27 Requested QoS Not Supported +*/ +#define BLE_HCI_INSTANT_PASSED 0x28 +#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29 +#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A +/* +0x2B Reserved +0x2C QoS Unacceptable Parameter +0x2D QoS Rejected +0x2E Channel Classification Not Supported +0x2F Insufficient Security +0x30 Parameter Out Of Mandatory Range +0x31 Reserved +0x32 Role Switch Pending +0x33 Reserved +0x34 Reserved Slot Violation +0x35 Role Switch Failed +0x36 Extended Inquiry Response Too Large +0x37 Secure Simple Pairing Not Supported By Host. +0x38 Host Busy - Pairing +0x39 Connection Rejected due to No Suitable Channel Found*/ +#define BLE_HCI_CONTROLLER_BUSY 0x3A +#define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B +#define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C +#define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D +#define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E + +/** @} */ + + +#endif // BLE_HCI_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_l2cap.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_l2cap.h new file mode 100644 index 0000000000..d4dd1eaa3d --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_l2cap.h @@ -0,0 +1,136 @@ +/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ +/** + @addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP) + @{ + @brief Definitions and prototypes for the L2CAP interface. + */ + +#ifndef BLE_L2CAP_H__ +#define BLE_L2CAP_H__ + +#include "nordic_global.h" +#include "ble_types.h" +#include "ble_ranges.h" +#include "ble_err.h" +#include "nrf_svc.h" + +/**@brief L2CAP API SVC numbers. */ +enum BLE_L2CAP_SVCS +{ + SD_BLE_L2CAP_CID_REGISTER = BLE_L2CAP_SVC_BASE, /**< Register a CID. */ + SD_BLE_L2CAP_CID_UNREGISTER, /**< Unregister a CID. */ + SD_BLE_L2CAP_TX /**< Transmit a packet. */ +}; + +/**@addtogroup BLE_L2CAP_DEFINES Defines + * @{ */ + +/**@defgroup BLE_ERRORS_L2CAP SVC return values specific to L2CAP + * @{ */ +#define BLE_ERROR_L2CAP_CID_IN_USE (NRF_L2CAP_ERR_BASE + 0x000) /**< CID already in use. */ +/** @} */ + +/**@brief Default L2CAP MTU. */ +#define BLE_L2CAP_MTU_DEF (23) + +/**@brief Invalid Channel Identifier. */ +#define BLE_L2CAP_CID_INVALID (0x0000) + +/**@brief Dynamic Channel Identifier base. */ +#define BLE_L2CAP_CID_DYN_BASE (0x0040) + +/**@brief Maximum amount of dynamic CIDs. */ +#define BLE_L2CAP_CID_DYN_MAX (8) + +/** @} */ + +/**@brief Packet header format for L2CAP transmission. */ +typedef struct +{ + uint16_t len; /**< Length of valid info in data member. */ + uint16_t cid; /**< Channel ID on which packet is transmitted. */ +} ble_l2cap_header_t; + +/**@brief L2CAP Event IDs. */ +enum BLE_L2CAP_EVTS +{ + BLE_L2CAP_EVT_RX = BLE_L2CAP_EVT_BASE /**< L2CAP packet received. */ +}; + + +/**@brief L2CAP Received packet event report. */ +typedef struct +{ + ble_l2cap_header_t header; /** L2CAP packet header. */ + uint8_t data[1]; /**< Packet data, variable length. */ +} ble_l2cap_evt_rx_t; + + +/**@brief L2CAP event callback event structure. */ +typedef struct +{ + uint16_t conn_handle; /**< Connection Handle on which event occured. */ + union + { + ble_l2cap_evt_rx_t rx; /**< RX Event parameters. */ + } params; +} ble_l2cap_evt_t; + + +/**@brief Register a CID with L2CAP. + * + * @details This registers a higher protocol layer with the L2CAP multiplexer, and is requried prior to all operations on the CID. + * + * @param[in] cid L2CAP CID. + * + * @return @ref NRF_SUCCESS Successfully registered a CID with the L2CAP layer. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CID must be above @ref BLE_L2CAP_CID_DYN_BASE. + * @return @ref BLE_ERROR_L2CAP_CID_IN_USE L2CAP CID already in use. + * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. + */ +SVCALL(SD_BLE_L2CAP_CID_REGISTER, uint32_t, sd_ble_l2cap_cid_register(uint16_t cid)); + +/**@brief Unregister a CID with L2CAP. + * + * @details This unregisters a previously registerd higher protocol layer with the L2CAP multiplexer. + * + * @param[in] cid L2CAP CID. + * + * @return @ref NRF_SUCCESS Successfully unregistered the CID. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. + * @return @ref NRF_ERROR_NOT_FOUND CID not previously registered. + */ +SVCALL(SD_BLE_L2CAP_CID_UNREGISTER, uint32_t, sd_ble_l2cap_cid_unregister(uint16_t cid)); + +/**@brief Transmit an L2CAP packet. + * + * @note It is important to note that a call to this function will consume an application buffer, and will therefore + * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. + * Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details. + * + * @param[in] conn_handle Connection Handle. + * @param[in] p_header Pointer to a packet header containing length and CID. + * @param[in] p_data Pointer to the data to be transmitted. + * + * @return @ref NRF_SUCCESS Successfully queued an L2CAP packet for transmission. + * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. + * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register. + * @return @ref NRF_ERROR_NOT_FOUND CID not found. + * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. + * @return @ref BLE_ERROR_NO_TX_BUFFERS Not enough application buffers available. + * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF. + */ +SVCALL(SD_BLE_L2CAP_TX, uint32_t, sd_ble_l2cap_tx(uint16_t conn_handle, ble_l2cap_header_t const * const p_header, uint8_t const * const p_data)); + + +#endif // BLE_L2CAP_H__ + +/** + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_ranges.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_ranges.h new file mode 100644 index 0000000000..c99e3556c4 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_ranges.h @@ -0,0 +1,72 @@ +/* + Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + + The information contained herein is confidential property of Nordic Semiconductor. The use, + copying, transfer or disclosure of such information is prohibited except by express written + agreement with Nordic Semiconductor. + */ +/** + @addtogroup BLE_COMMON + @{ + @defgroup ble_ranges Module specific SVC and event number subranges + @{ + + @brief Definition of SVC and event number subranges for each API module. + + @note + SVCs and event numbers are split into subranges for each API module. + Each module receives its entire allocated range of SVC calls, whether implemented or not, + but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range. + + Note that the symbols BLE__SVC_LAST is the end of the allocated SVC range, + rather than the last SVC function call actually defined and implemented. + + Specific SVC and event values are defined in each module's ble_.h file, + which defines names of each individual SVC code based on the range start value. +*/ + +#ifndef BLE_RANGES_H__ +#define BLE_RANGES_H__ + +#define BLE_SVC_BASE 0x60 +#define BLE_SVC_LAST 0x6B /* Total: 12. */ + +#define BLE_RESERVED_SVC_BASE 0x6C +#define BLE_RESERVED_SVC_LAST 0x6F /* Total: 4. */ + +#define BLE_GAP_SVC_BASE 0x70 +#define BLE_GAP_SVC_LAST 0x8F /* Total: 32. */ + +#define BLE_GATTC_SVC_BASE 0x90 +#define BLE_GATTC_SVC_LAST 0x9F /* Total: 16. */ + +#define BLE_GATTS_SVC_BASE 0xA0 +#define BLE_GATTS_SVC_LAST 0xAF /* Total: 16. */ + +#define BLE_L2CAP_SVC_BASE 0xB0 +#define BLE_L2CAP_SVC_LAST 0xBF /* Total: 16. */ + + +#define BLE_EVT_INVALID 0x00 + +#define BLE_EVT_BASE 0x01 +#define BLE_EVT_LAST 0x0F /* Total: 15. */ + +#define BLE_GAP_EVT_BASE 0x10 +#define BLE_GAP_EVT_LAST 0x2F /* Total: 32. */ + +#define BLE_GATTC_EVT_BASE 0x30 +#define BLE_GATTC_EVT_LAST 0x4F /* Total: 32. */ + +#define BLE_GATTS_EVT_BASE 0x50 +#define BLE_GATTS_EVT_LAST 0x6F /* Total: 32. */ + +#define BLE_L2CAP_EVT_BASE 0x70 +#define BLE_L2CAP_EVT_LAST 0x8F /* Total: 32. */ + +#endif /* BLE_RANGES_H__ */ + +/** + @} + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_types.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_types.h new file mode 100644 index 0000000000..6f5ab22d6a --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/ble_types.h @@ -0,0 +1,158 @@ +/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ +/** + @addtogroup BLE_COMMON + @{ + @defgroup ble_types Common types and macro definitions + @{ + + @brief Common types and macro definitions for the S110 SoftDevice. + */ + +#ifndef BLE_TYPES_H__ +#define BLE_TYPES_H__ + +#include +#include "nordic_global.h" + +/** @addtogroup BLE_COMMON_DEFINES Defines + * @{ */ + +/** @defgroup BLE_CONN_HANDLES BLE Connection Handles + * @{ */ +#define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */ +#define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */ +/** @} */ + + +/** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs + * @{ */ +/* Generic UUIDs, applicable to all services */ +#define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */ +#define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */ +#define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */ +#define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */ +#define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */ +#define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */ +#define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */ +#define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */ +/* GATT specific UUIDs */ +#define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */ +#define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */ +/* GAP specific UUIDs */ +#define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */ +#define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_PPF 0x2A02 /**< Peripheral Privacy Flag Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */ +#define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */ +/** @} */ + + +/** @defgroup BLE_UUID_TYPES Types of UUID + * @{ */ +#define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */ +#define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */ +#define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */ +/** @} */ + + +/** @defgroup BLE_APPEARANCES Bluetooth Appearance values + * @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml + * @{ */ +#define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */ +#define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */ +#define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */ +#define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */ +#define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */ +#define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */ +#define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */ +#define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */ +#define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */ +#define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */ +#define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */ +#define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */ +#define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */ +#define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */ +#define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */ +#define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */ +#define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */ +#define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */ +#define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */ +#define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */ +#define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */ +#define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */ +#define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */ +#define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystiq (HID Subtype). */ +#define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */ +#define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */ +#define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */ +#define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */ +#define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */ +#define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */ +#define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */ +#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */ +#define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */ +#define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */ +#define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */ +#define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */ +#define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */ +#define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */ +/** @} */ + +/** @brief Set .type and .uuid fields of ble_uuid_struct to specified uuid value. */ +#define BLE_UUID_BLE_ASSIGN(instance, value) do {\ + instance.type = BLE_UUID_TYPE_BLE; \ + instance.uuid = value;} while(0) + +/** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */ +#define BLE_UUID_COPY_PTR(dst, src) do {\ + (dst)->type = (src)->type; \ + (dst)->uuid = (src)->uuid;} while(0) + +/** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */ +#define BLE_UUID_COPY_INST(dst, src) do {\ + (dst).type = (src).type; \ + (dst).uuid = (src).uuid;} while(0) + +/** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */ +#define BLE_UUID_EQ(p_uuid1, p_uuid2) \ + (((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid)) + +/** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */ +#define BLE_UUID_NEQ(p_uuid1, p_uuid2) \ + (((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid)) + +/** @} */ + +/** @brief 128 bit UUID values. */ +typedef struct +{ + unsigned char uuid128[16]; +} ble_uuid128_t; + +/** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */ +typedef struct +{ + uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */ + uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */ +} ble_uuid_t; + + + +#endif /* BLE_TYPES_H__ */ + +/** + @} + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error.h new file mode 100644 index 0000000000..518ef82b8f --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ + /** + @defgroup nrf_error SoftDevice Global Error Codes + @{ + + @brief Global Error definitions +*/ + +/* Header guard */ +#ifndef NRF_ERROR_H__ +#define NRF_ERROR_H__ + +/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions + * @{ */ +#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base +#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base +#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base +#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base +/** @} */ + +#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command +#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing +#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled +#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error +#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation +#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found +#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported +#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter +#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state +#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length +#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags +#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data +#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Data size exceeds limit +#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out +#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer +#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation +#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address +#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy + +#endif // NRF_ERROR_H__ + +/** + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error_sdm.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error_sdm.h new file mode 100644 index 0000000000..ea5413ff3f --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error_sdm.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ + /** + @addtogroup nrf_sdm_api + @{ + @defgroup nrf_sdm_error SoftDevice Manager Error Codes + @{ + + @brief Error definitions for the SDM API +*/ + +/* Header guard */ +#ifndef NRF_ERROR_SDM_H__ +#define NRF_ERROR_SDM_H__ + +#include "nrf_error.h" + +#define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown lfclk source +#define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts) +#define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing) + +#endif // NRF_ERROR_SDM_H__ + +/** + @} + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error_soc.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error_soc.h new file mode 100644 index 0000000000..08dc13c3e7 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_error_soc.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ + /** + @addtogroup nrf_soc_api + @{ + @defgroup nrf_soc_error SoC Library Error Codes + @{ + + @brief Error definitions for the SoC library + +*/ + +/* Header guard */ +#ifndef NRF_ERROR_SOC_H__ +#define NRF_ERROR_SOC_H__ + +#include "nrf_error.h" + +/* Mutex Errors */ +#define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken + +/* NVIC errors */ +#define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available +#define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed +#define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return + +/* Power errors */ +#define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown +#define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown +#define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return + +/* Rand errors */ +#define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values + +/* PPI errors */ +#define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel +#define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group + +#endif // NRF_ERROR_SOC_H__ +/** + @} + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_sdm.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_sdm.h new file mode 100644 index 0000000000..6a46aba61e --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_sdm.h @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ +/** + @defgroup nrf_sdm_api SoftDevice Manager API + @{ + + @brief APIs for SoftDevice management. + +*/ + +/* Header guard */ +#ifndef NRF_SDM_H__ +#define NRF_SDM_H__ + +#include "nordic_global.h" +#include "nrf_svc.h" +#include "nrf51.h" +#include "nrf_soc.h" +#include "nrf_error_sdm.h" + +/** @addtogroup NRF_SDM_DEFINES Defines + * @{ */ + +/**@brief SoftDevice Manager SVC Base number. */ +#define SDM_SVC_BASE 0x10 + +/** @} */ + +/** @addtogroup NRF_SDM_ENUMS Enumerations + * @{ */ + +/**@brief nRF SoftDevice Manager API SVC numbers. */ +enum NRF_SD_SVCS +{ + SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */ + SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */ + SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */ + SD_SOFTDEVICE_FORWARD_TO_APPLICATION,/**< ::sd_softdevice_forward_to_application */ + SVC_SDM_LAST /**< Placeholder for last SDM SVC */ +}; + +/**@brief Possible lfclk oscillator sources. */ +enum NRF_CLOCK_LFCLKSRCS +{ + NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, /**< LFCLK Synthesized from HFCLK. */ + NRF_CLOCK_LFCLKSRC_XTAL_500_PPM, /**< LFCLK crystal oscillator 500 PPM accuracy. */ + NRF_CLOCK_LFCLKSRC_XTAL_250_PPM, /**< LFCLK crystal oscillator 250 PPM accuracy. */ + NRF_CLOCK_LFCLKSRC_XTAL_150_PPM, /**< LFCLK crystal oscillator 150 PPM accuracy. */ + NRF_CLOCK_LFCLKSRC_XTAL_100_PPM, /**< LFCLK crystal oscillator 100 PPM accuracy. */ + NRF_CLOCK_LFCLKSRC_XTAL_75_PPM, /**< LFCLK crystal oscillator 75 PPM accuracy. */ + NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, /**< LFCLK crystal oscillator 50 PPM accuracy. */ + NRF_CLOCK_LFCLKSRC_XTAL_30_PPM, /**< LFCLK crystal oscillator 30 PPM accuracy. */ + NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, /**< LFCLK crystal oscillator 20 PPM accuracy. */ + NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, /**< LFCLK RC oscillator, 250ms calibration interval.*/ + NRF_CLOCK_LFCLKSRC_RC_250_PPM_500MS_CALIBRATION, /**< LFCLK RC oscillator, 500ms calibration interval.*/ + NRF_CLOCK_LFCLKSRC_RC_250_PPM_1000MS_CALIBRATION, /**< LFCLK RC oscillator, 1000ms calibration interval.*/ + NRF_CLOCK_LFCLKSRC_RC_250_PPM_2000MS_CALIBRATION, /**< LFCLK RC oscillator, 2000ms calibration interval.*/ + NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, /**< LFCLK RC oscillator, 4000ms calibration interval.*/ + NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION, /**< LFCLK RC oscillator, 8000ms calibration interval.*/ +}; + +/** @} */ + +/** @addtogroup NRF_SDM_TYPES Types + * @{ */ + +/**@brief Type representing lfclk oscillator source. */ +typedef uint32_t nrf_clock_lfclksrc_t; + + +/**@brief SoftDevice Assertion Handler type. + * + * When an unexpected error occurs within the SoftDevice it will call the SoftDevice assertion handler callback. + * The protocol stack will be in an undefined state when this happens and the only way to recover will be to + * perform a reset, using e.g. CMSIS NVIC_SystemReset(). + * + * @note This callback is executed in HardFault context, thus SVC functions cannot be called from the SoftDevice assert callback. + * + * @param[in] pc The program counter of the failed assert. + * @param[in] line_number Line number where the assert failed. + * @param[in] file_name File name where the assert failed. + */ +typedef void (*softdevice_assertion_handler_t)(uint32_t pc, uint16_t line_number, const uint8_t * p_file_name); + +/** @} */ + +/** @addtogroup NRF_SDM_FUNCTIONS Functions + * @{ */ + +/**@brief Enables the SoftDevice and by extension the protocol stack. + * + * Idempotent function to enable the SoftDevice. + * + * @note Some care must be taken if a low frequency clock source is already running when calling this function: + * If the LF clock has a different source then the one currently running, it will be stopped. Then, the new + * clock source will be started. + * + * @note This function has no effect when returning with an error. + * + * @post If return code is ::NRF_SUCCESS + * - SoC library and protocol stack APIs are made available + * - A portion of RAM will be unavailable (see relevant SDS documentation) + * - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation) + * - Interrupts will not arrive from protected peripherals or interrupts + * - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the softdevice. + * - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation) + * - Chosen low frequency clock source will be running + * + * @param clock_source Low frequency clock source and accuracy. (Note: In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock). + * @param assertion_handler Callback for SoftDevice assertions. + * + * @retval ::NRF_SUCCESS + * @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDeviceinterrupt is already enabled, or an enabled interrupt has an illegal priority level + * @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected + */ +SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lfclksrc_t clock_source, softdevice_assertion_handler_t assertion_handler)); + +/**@brief Disables the SoftDevice and by extension the protocol stack. + * + * Idempotent function to disable the SoftDevice. + * + * @post SoC library and protocol stack APIs are made unavailable. + * @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest). + * @post All peripherals used by the SoftDevice will be reset to default values. + * @post All of RAM become available. + * @post All interrupts are forwarded to the application. + * @post LFCLK source chosen in ::sd_softdevice_enable will be left running. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void)); + +/**@brief Check if the SoftDevice is enabled. + * + * @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled)); + +/**@brief Start forwarding interrupts to application. + * + * This function is only intended to be called when a bootloader is enabled is used. + * The bootloader should call this right before it starts the application. + * It is recommended that all interrupt sources are off when this is called, + * or you could end up having interrupts in the application being executed before main() of the application. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_SOFTDEVICE_FORWARD_TO_APPLICATION, uint32_t, sd_softdevice_forward_to_application(void)); + +/** @} */ + +#endif // NRF_SDM_H__ + +/** + @} +*/ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_soc.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_soc.h new file mode 100644 index 0000000000..8b7c137dd6 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_soc.h @@ -0,0 +1,778 @@ +/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ + +/** + @defgroup nrf_soc_api SoC Library API + @{ + + @brief APIs for the SoC library. + +*/ + +#ifndef NRF_SOC_H__ +#define NRF_SOC_H__ + +#include +#include +#include "nordic_global.h" +#include "nrf_svc.h" +#include "nrf51.h" +#include "nrf51_bitfields.h" +#include "nrf_error_soc.h" + +/** @addtogroup NRF_SOC_DEFINES Defines + * @{ */ + +/**@brief The number of the lowest SVC number reserved for the SoC library. */ +#define SOC_SVC_BASE 0x20 + +/**@brief Guranteed time for application to process radio inactive notification. */ +#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62) + +#define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */ +#define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */ +#define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */ + +#define SD_EVT_IRQn (SWI2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */ +#define SD_EVT_IRQHandler (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */ +#define RADIO_NOTIFICATION_IRQn (SWI1_IRQn) /**< The radio notification IRQ number. */ +#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. */ + +/** @} */ + +/** @addtogroup NRF_SOC_TYPES Types + * @{ */ + +/**@brief The SVC numbers used by the SVC functions in the SoC library. */ +enum NRF_SOC_SVCS +{ + SD_MUTEX_NEW = SOC_SVC_BASE, + SD_MUTEX_ACQUIRE, + SD_MUTEX_RELEASE, + SD_NVIC_ENABLEIRQ, + SD_NVIC_DISABLEIRQ, + SD_NVIC_GETPENDINGIRQ, + SD_NVIC_SETPENDINGIRQ, + SD_NVIC_CLEARPENDINGIRQ, + SD_NVIC_SETPRIORITY, + SD_NVIC_GETPRIORITY, + SD_NVIC_SYSTEMRESET, + SD_NVIC_CRITICAL_REGION_ENTER, + SD_NVIC_CRITICAL_REGION_EXIT, + SD_RAND_APPLICATION_POOL_CAPACITY, + SD_RAND_APPLICATION_BYTES_AVAILABLE, + SD_RAND_APPLICATION_GET_VECTOR, + SD_POWER_MODE_SET, + SD_POWER_SYSTEM_OFF, + SD_POWER_RESET_REASON_GET, + SD_POWER_RESET_REASON_CLR, + SD_POWER_POF_ENABLE, + SD_POWER_POF_THRESHOLD_SET, + SD_POWER_RAMON_SET, + SD_POWER_RAMON_CLR, + SD_POWER_RAMON_GET, + SD_POWER_GPREGRET_SET, + SD_POWER_GPREGRET_CLR, + SD_POWER_GPREGRET_GET, + SD_POWER_DCDC_MODE_SET, + SD_APP_EVT_WAIT, + SD_CLOCK_HFCLK_REQUEST, + SD_CLOCK_HFCLK_RELEASE, + SD_CLOCK_HFCLK_IS_RUNNING, + SD_PPI_CHANNEL_ENABLE_GET, + SD_PPI_CHANNEL_ENABLE_SET, + SD_PPI_CHANNEL_ENABLE_CLR, + SD_PPI_CHANNEL_ASSIGN, + SD_PPI_GROUP_TASK_ENABLE, + SD_PPI_GROUP_TASK_DISABLE, + SD_PPI_GROUP_ASSIGN, + SD_PPI_GROUP_GET, + SD_RADIO_NOTIFICATION_CFG_SET, + SD_ECB_BLOCK_ENCRYPT, + SD_RESERVED1, + SD_RESERVED2, + SD_RESERVED3, + SD_EVT_GET, + SD_TEMP_GET, + SD_FLASH_ERASE_PAGE, + SD_FLASH_WRITE, + SD_FLASH_PROTECT, + SVC_SOC_LAST +}; + +/**@brief Possible values of a ::nrf_mutex_t. */ +enum NRF_MUTEX_VALUES +{ + NRF_MUTEX_FREE, + NRF_MUTEX_TAKEN +}; + +/**@brief Possible values of ::nrf_app_irq_priority_t. */ +enum NRF_APP_PRIORITIES +{ + NRF_APP_PRIORITY_HIGH = 1, + NRF_APP_PRIORITY_LOW = 3 +}; + +/**@brief Possible values of ::nrf_power_mode_t. */ +enum NRF_POWER_MODES +{ + NRF_POWER_MODE_CONSTLAT, /**< Constant latency mode. See power management in the reference manual. */ + NRF_POWER_MODE_LOWPWR /**< Low power mode. See power management in the reference manual. */ +}; + + +/**@brief Possible values of ::nrf_power_failure_threshold_t */ +enum NRF_POWER_THRESHOLDS +{ + NRF_POWER_THRESHOLD_V21, /**< 2.1 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V23, /**< 2.3 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V25, /**< 2.5 Volts power failure threshold. */ + NRF_POWER_THRESHOLD_V27 /**< 2.7 Volts power failure threshold. */ +}; + + +/**@brief Possible values of ::nrf_power_dcdc_mode_t. */ +enum NRF_POWER_DCDC_MODES +{ + NRF_POWER_DCDC_MODE_OFF, /**< The DCDC is always off. */ + NRF_POWER_DCDC_MODE_ON, /**< The DCDC is always on. */ + NRF_POWER_DCDC_MODE_AUTOMATIC /**< The DCDC is automatically managed. */ +}; + +/**@brief Possible values of ::nrf_radio_notification_distance_t. */ +enum NRF_RADIO_NOTIFICATION_DISTANCES +{ + NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */ + NRF_RADIO_NOTIFICATION_DISTANCE_800US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_1740US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_2680US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_3620US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_4560US, /**< The distance from the active notification to start of radio activity. */ + NRF_RADIO_NOTIFICATION_DISTANCE_5500US /**< The distance from the active notification to start of radio activity. */ +}; + + +/**@brief Possible values of ::nrf_radio_notification_type_t. */ +enum NRF_RADIO_NOTIFICATION_TYPES +{ + NRF_RADIO_NOTIFICATION_TYPE_NONE = 0, /**< The event does not have a radio notification signal. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */ + NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */ +}; + +/**@brief SoC Events. */ +enum NRF_SOC_EVTS +{ + NRF_EVT_HFCLKSTARTED, /**< Event indicating that the HFCLK has started. */ + NRF_EVT_POWER_FAILURE_WARNING, /**< Event indicating that a power failure warning has occurred. */ + NRF_EVT_FLASH_OPERATION_SUCCESS, /**< Event indicating that the ongoing flash operation has completed successfully. */ + NRF_EVT_FLASH_OPERATION_ERROR, /**< Event indicating that the ongoing flash operation has timed out with an error. */ + NRF_EVT_RESERVED1, + NRF_EVT_RESERVED2, + NRF_EVT_RESERVED3, + NRF_EVT_RESERVED4, + NRF_EVT_RESERVED5, + NRF_EVT_NUMBER_OF_EVTS +}; + +/** @} */ + +/** @addtogroup NRF_SOC_TYPES Types + * @{ */ + +/**@brief Represents a mutex for use with the nrf_mutex functions. + * @note Accessing the value directly is not safe, use the mutex functions! + */ +typedef volatile uint8_t nrf_mutex_t; + +/**@brief The interrupt priorities available to the application while the softdevice is active. */ +typedef uint8_t nrf_app_irq_priority_t; + +/**@brief Represents a power mode, used in power mode functions */ +typedef uint8_t nrf_power_mode_t; + +/**@brief Represents a power failure threshold value. */ +typedef uint8_t nrf_power_failure_threshold_t; + +/**@brief Represents a DCDC mode value. */ +typedef uint32_t nrf_power_dcdc_mode_t; + +/**@brief Radio notification distances. */ +typedef uint8_t nrf_radio_notification_distance_t; + +/**@brief Radio notification types. */ +typedef uint8_t nrf_radio_notification_type_t; + + +/**@brief AES ECB data structure */ +typedef struct +{ + uint8_t key[SOC_ECB_KEY_LENGTH]; /**< Encryption key. */ + uint8_t cleartext[SOC_ECB_CLEARTEXT_LENGTH]; /**< Clear Text data. */ + uint8_t ciphertext[SOC_ECB_CIPHERTEXT_LENGTH]; /**< Cipher Text data. */ +} nrf_ecb_hal_data_t; + +/** @} */ + +/** @addtogroup NRF_SOC_FUNCTIONS Functions + * @{ */ + +/**@brief Initialize a mutex. + * + * @param[in] p_mutex Pointer to the mutex to initialize. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex)); + +/**@brief Attempt to acquire a mutex. + * + * @param[in] p_mutex Pointer to the mutex to acquire. + * + * @retval ::NRF_SUCCESS The mutex was successfully acquired. + * @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired. + */ +SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex)); + +/**@brief Release a mutex. + * + * @param[in] p_mutex Pointer to the mutex to release. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex)); + +/**@brief Enable External Interrupt. + * @note Corresponds to NVIC_EnableIRQ in CMSIS. + * + * @pre{IRQn is valid and not reserved by the stack} + * + * @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt was enabled. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application. + */ +SVCALL(SD_NVIC_ENABLEIRQ, uint32_t, sd_nvic_EnableIRQ(IRQn_Type IRQn)); + +/**@brief Disable External Interrupt. + * @note Corresponds to NVIC_DisableIRQ in CMSIS. + * + * @pre{IRQn is valid and not reserved by the stack} + * + * @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS + * + * @retval ::NRF_SUCCESS The interrupt was disabled. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application. + */ +SVCALL(SD_NVIC_DISABLEIRQ, uint32_t, sd_nvic_DisableIRQ(IRQn_Type IRQn)); + +/**@brief Get Pending Interrupt. + * @note Corresponds to NVIC_GetPendingIRQ in CMSIS. + * + * @pre{IRQn is valid and not reserved by the stack} + * + * @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS. + * @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ. + * + * @retval ::NRF_SUCCESS The interrupt is available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +SVCALL(SD_NVIC_GETPENDINGIRQ, uint32_t, sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq)); + +/**@brief Set Pending Interrupt. + * @note Corresponds to NVIC_SetPendingIRQ in CMSIS. + * + * @pre{IRQn is valid and not reserved by the stack} + * + * @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt is set pending. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +SVCALL(SD_NVIC_SETPENDINGIRQ, uint32_t, sd_nvic_SetPendingIRQ(IRQn_Type IRQn)); + +/**@brief Clear Pending Interrupt. + * @note Corresponds to NVIC_ClearPendingIRQ in CMSIS. + * + * @pre{IRQn is valid and not reserved by the stack} + * + * @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS. + * + * @retval ::NRF_SUCCESS The interrupt pending flag is cleared. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + */ +SVCALL(SD_NVIC_CLEARPENDINGIRQ, uint32_t, sd_nvic_ClearPendingIRQ(IRQn_Type IRQn)); + +/**@brief Set Interrupt Priority. + * @note Corresponds to NVIC_SetPriority in CMSIS. + * + * @pre{IRQn is valid and not reserved by the stack} + * @pre{priority is valid and not reserved by the stack} + * + * @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS. + * @param[in] priority A valid IRQ priority for use by the application. + * + * @retval ::NRF_SUCCESS The interrupt and priority level is available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application. + */ +SVCALL(SD_NVIC_SETPRIORITY, uint32_t, sd_nvic_SetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t priority)); + +/**@brief Get Interrupt Priority. + * @note Corresponds to NVIC_GetPriority in CMSIS. + * + * @pre{IRQn is valid and not reserved by the stack} + * + * @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS. + * @param[out] p_priority Return value from NVIC_GetPriority. + * + * @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority. + * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application. + */ +SVCALL(SD_NVIC_GETPRIORITY, uint32_t, sd_nvic_GetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t * p_priority)); + +/**@brief System Reset. + * @note Corresponds to NVIC_SystemReset in CMSIS. + * + * @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN + */ +SVCALL(SD_NVIC_SYSTEMRESET, uint32_t, sd_nvic_SystemReset(void)); + +/**@brief Enters critical region. + * + * @post Application interrupts will be disabled. + * @sa sd_nvic_critical_region_exit + * + * @param[out] p_is_nested_critical_region 1: If in a nested critical region. + * 0: Otherwise. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_NVIC_CRITICAL_REGION_ENTER, uint32_t, sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region)); + +/**@brief Exit critical region. + * + * @pre Application has entered a critical region using ::sd_nvic_critical_region_enter. + * @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called. + * + * @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_NVIC_CRITICAL_REGION_EXIT, uint32_t, sd_nvic_critical_region_exit(uint8_t is_nested_critical_region)); + +/**@brief Query the capacity of the application random pool. + * + * @param[out] p_pool_capacity The capacity of the pool. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity)); + +/**@brief Get number of random bytes available to the application. + * + * @param[out] p_bytes_available The number of bytes currently available in the pool. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available)); + +/**@brief Get random bytes from the application pool. + + @param[out] p_buff Pointer to unit8_t buffer for storing the bytes. + @param[in] length Number of bytes to take from pool and place in p_buff. + + @retval ::NRF_SUCCESS The requested bytes were written to p_buff. + @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available. +*/ +SVCALL(SD_RAND_APPLICATION_GET_VECTOR, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length)); + +/**@brief Gets the reset reason register. + * + * @param[out] p_reset_reason Contents of the NRF_POWER->RESETREAS register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason)); + +/**@brief Clears the bits of the reset reason register. + * + * @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk)); + +/**@brief Sets the power mode when in CPU sleep. + * + * @param[in] power_mode The power mode to use when in CPU sleep. @sa sd_app_evt_wait + * + * @retval ::NRF_SUCCESS The power mode was set. + * @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown. + */ +SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(nrf_power_mode_t power_mode)); + +/**@brief Puts the chip in System OFF mode. + * + * @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN + */ +SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void)); + +/**@brief Enables or disables the power-fail comparator. + * + * Enabling this will give a softdevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs. + * The event can be retrieved with sd_evt_get(); + * + * @param[in] pof_enable True if the power-fail comparator should be enabled, false if it should be disabled. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable)); + +/**@brief Sets the power-fail threshold value. + * + * @param[in] threshold The power-fail threshold value to use. + * + * @retval ::NRF_SUCCESS The power failure threshold was set. + * @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown. + */ +SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(nrf_power_failure_threshold_t threshold)); + +/**@brief Sets bits in the NRF_POWER->RAMON register. + * + * @param[in] ramon Contains the bits needed to be set in the NRF_POWER->RAMON register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAMON_SET, uint32_t, sd_power_ramon_set(uint32_t ramon)); + +/** @brief Clears bits in the NRF_POWER->RAMON register. + * + * @param ramon Contains the bits needed to be cleared in the NRF_POWER->RAMON register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAMON_CLR, uint32_t, sd_power_ramon_clr(uint32_t ramon)); + +/**@brief Get contents of NRF_POWER->RAMON register, indicates power status of ram blocks. + * + * @param[out] p_ramon Content of NRF_POWER->RAMON register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_RAMON_GET, uint32_t, sd_power_ramon_get(uint32_t * p_ramon)); + +/**@brief Set bits in the NRF_POWER->GPREGRET register. + * + * @param[in] gpregret_msk Bits to be set in the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_msk)); + +/**@brief Clear bits in the NRF_POWER->GPREGRET register. + * + * @param[in] gpregret_msk Bits to be clear in the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_msk)); + +/**@brief Get contents of the NRF_POWER->GPREGRET register. + * + * @param[out] p_gpregret Contents of the GPREGRET register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t *p_gpregret)); + +/**@brief Sets the DCDC mode. + * + * Depending on the internal state of the SoftDevice, the mode change may not happen immediately. + * The DCDC mode switch will be blocked when occurring in close proximity to radio transmissions. When + * the radio transmission is done, the last mode will be used. + * + * @param[in] dcdc_mode The mode of the DCDC. + * + * @retval ::NRF_SUCCESS + * @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid. + */ +SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(nrf_power_dcdc_mode_t dcdc_mode)); + +/**@brief Request the high frequency crystal oscillator. + * + * Will start the high frequency crystal oscillator, the startup time of the crystal varies + * and the ::sd_clock_hfclk_is_running function can be polled to check if it has started. + * + * @see sd_clock_hfclk_is_running + * @see sd_clock_hfclk_release + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void)); + +/**@brief Releases the high frequency crystal oscillator. + * + * Will stop the high frequency crystal oscillator, this happens immediately. + * + * @see sd_clock_hfclk_is_running + * @see sd_clock_hfclk_request + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void)); + +/**@brief Checks if the high frequency crystal oscillator is running. + * + * @see sd_clock_hfclk_request + * @see sd_clock_hfclk_release + * + * @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running)); + +/**@brief Waits for an application event. + * + * An application event is either an application interrupt or a pended interrupt when the + * interrupt is disabled. When the interrupt is enabled it will be taken immediately since + * this function will wait in thread mode, then the execution will return in the application's + * main thread. When an interrupt is disabled and gets pended it will return to the application's + * thread main. The application must ensure that the pended flag is cleared using + * ::sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for + * disabled interrupts, as the interrupt handler will clear the pending flag automatically for + * enabled interrupts. + * + * In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M0 + * System Control Register (SCR). @sa CMSIS_SCB + * + * @note If an application interrupt has happened since the last time sd_app_evt_wait was + * called this function will return immediately and not go to sleep. This is to avoid race + * conditions that can occur when a flag is updated in the interrupt handler and processed + * in the main loop. + * + * @post An application interrupt has happened or a interrupt pending flag is set. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void)); + +/**@brief Get PPI channel enable register contents. + * + * @param[out] p_channel_enable The contents of the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable)); + +/**@brief Set PPI channel enable register. + * + * @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk)); + +/**@brief Clear PPI channel enable register. + * + * @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register. + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk)); + +/**@brief Assign endpoints to a PPI channel. + * + * @param[in] channel_num Number of the PPI channel to assign. + * @param[in] evt_endpoint Event endpoint of the PPI channel. + * @param[in] task_endpoint Task endpoint of the PPI channel. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint)); + +/**@brief Task to enable a channel group. + * + * @param[in] group_num Number of the channel group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num)); + +/**@brief Task to disable a channel group. + * + * @param[in] group_num Number of the PPI group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num)); + +/**@brief Assign PPI channels to a channel group. + * + * @param[in] group_num Number of the channel group. + * @param[in] channel_msk Mask of the channels to assign to the group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk)); + +/**@brief Gets the PPI channels of a channel group. + * + * @param[in] group_num Number of the channel group. + * @param[out] p_channel_msk Mask of the channels assigned to the group. + * + * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk)); + +/**@brief Configures the Radio Notification signal. + * + * @note + * - The notification signal latency depends on the interrupt priority settings of SWI used + * for notification signal. + * - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice + * will interrupt the application to do Radio Event preparation. + * - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have + * to shorten the connection events to have time for the Radio Notification signals. + * + * @param[in] type Type of notification signal. + * @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio + * notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is + * recommended (but not required) to be used with + * @ref NRF_RADIO_NOTIFICATION_TYPE_NONE. + * + * @param[in] distance Distance between the notification signal and start of radio activity. + * This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or + * @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used. + * + * @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid. + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(nrf_radio_notification_type_t type, nrf_radio_notification_distance_t distance)); + +/**@brief Encrypts a block according to the specified parameters. + * + * 128-bit AES encryption. + * + * @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input + * parameters and one output parameter). + * + * @retval ::NRF_SUCCESS + */ +SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data)); + +/**@brief Gets any pending events generated by the SoC API. + * + * The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned. + * + * @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending. + * + * @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter. + * @retval ::NRF_ERROR_NOT_FOUND No pending events. + */ +SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id)); + +/**@brief Get the temperature measured on the chip + * + * This function will block until the temperature measurement is done. + * It takes around 50us from call to return. + * + * @note Pan #28 in PAN-028 v 1.6 "Negative measured values are not represented correctly" is corrected by this function. + * + * @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees celsius. + * + * @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp + */ +SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp)); + +/**@brief Flash Write + * + * Commands to write a buffer to flash + * + * This call initiates the flash access command, and its completion will be communicated to the + * application with exactly one of the following events: + * - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed. + * - NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started. + * + * @note + * - This call takes control over the radio and the CPU during flash erase and write to make sure that + * they will not interfere with the flash access. This means that all interrupts will be blocked + * for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual + * and the command parameters). + * + * + * @param[in] p_dst Pointer to start of flash location to be written. + * @param[in] p_src Pointer to buffer with data to be written + * @param[in] size Number of 32-bit words to write. Maximum size is 256 32bit words. + * + * @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned. + * @retval ::NRF_ERROR_BUSY The previous command has not yet completed. + * @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or more than 256 words. + * @retval ::NRF_ERROR_FORBIDDEN Tried to write to or read from protected location. + * @retval ::NRF_SUCCESS The command was accepted. + */ +SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size)); + + +/**@brief Flash Erase page + * + * Commands to erase a flash page + * + * This call initiates the flash access command, and its completion will be communicated to the + * application with exactly one of the following events: + * - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed. + * - NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started. + * + * @note + * - This call takes control over the radio and the CPU during flash erase and write to make sure that + * they will not interfere with the flash access. This means that all interrupts will be blocked + * for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual + * and the command parameters). + * + * + * @param[in] page_number Pagenumber of the page to erase + * @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error. + * @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page. + * @retval ::NRF_ERROR_BUSY The previous command has not yet completed. + * @retval ::NRF_ERROR_FORBIDDEN Tried to erase a protected page. + * @retval ::NRF_SUCCESS The command was accepted. + */ +SVCALL(SD_FLASH_ERASE_PAGE, uint32_t, sd_flash_page_erase(uint32_t page_number)); + + +/**@brief Flash Protection set + * + * Commands to set the flash protection registers PROTENSETx + * + * @note To read the values in PROTENSETx you can read them directly. They are only write-protected. + * + * @param[in] protenset0 Value to be written to PROTENSET0 + * @param[in] protenset1 Value to be written to PROTENSET1 + * + * @retval ::NRF_ERROR_FORBIDDEN Tried to protect the SoftDevice + * @retval ::NRF_SUCCESS Values successfully written to PROTENSETx + */ +SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t protenset0, uint32_t protenset1)); + + +/** @} */ + +#endif // NRF_SOC_H__ + +/** + @} + */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_svc.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_svc.h new file mode 100644 index 0000000000..8f9f8064ec --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/nrf_svc.h @@ -0,0 +1,35 @@ +#ifndef NRF_SVC__ +#define NRF_SVC__ + +#include "nordic_global.h" + +#ifdef SVCALL_AS_NORMAL_FUNCTION +#define SVCALL(number, return_type, signature) return_type signature +#else + +#ifndef SVCALL +#if defined (__CC_ARM) +#define SVCALL(number, return_type, signature) return_type __svc(number) signature +#elif defined (__GNUC__) +#define SVCALL(number, return_type, signature) \ + _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ + _Pragma("GCC diagnostic ignored \"-Wunused-function\"") \ + __attribute__((naked)) static return_type signature \ + { \ + __asm( \ + "svc %0\n" \ + "bx r14" : : "I" (number) : "r0" \ + ); \ + } +#elif defined (__ICCARM__) +#define PRAGMA(x) _Pragma(#x) +#define SVCALL(number, return_type, signature) \ +PRAGMA(swi_number = number) \ + __swi return_type signature; +#else +#define SVCALL(number, return_type, signature) return_type signature +#endif +#endif // SVCALL + +#endif // SVCALL_AS_NORMAL_FUNCTION +#endif // NRF_SVC__ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/softdevice_assert.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/softdevice_assert.h new file mode 100644 index 0000000000..7026ee4ce5 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/s110/softdevice_assert.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is confidential property of Nordic Semiconductor. The use, + * copying, transfer or disclosure of such information is prohibited except by express written + * agreement with Nordic Semiconductor. + * + */ + +/** @brief Utilities for verifying program logic + */ + +#ifndef SOFTDEVICE_ASSERT_H_ +#define SOFTDEVICE_ASSERT_H_ + +#include +#include "nordic_global.h" + +/** @brief This function handles assertions. + * + * + * @note + * This function is called when an assertion has triggered. + * + * + * @param line_num The line number where the assertion is called + * @param file_name Pointer to the file name + */ +void assert_softdevice_callback(uint16_t line_num, const uint8_t *file_name); + + +/*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ +/*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \ +/** @brief Check intended for production code + * + * Check passes if "expr" evaluates to true. */ +#define ASSERT(expr) \ +if (expr) \ +{ \ +} \ +else \ +{ \ + assert_softdevice_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \ + /*lint -unreachable */ \ +} + +#endif /* SOFTDEVICE_ASSERT_H_ */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/ant_stack_handler_types.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/ant_stack_handler_types.h new file mode 100644 index 0000000000..f222b172e3 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/ant_stack_handler_types.h @@ -0,0 +1,70 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/**@file + * + * @defgroup ant_stack_handler_types Types definitions for ANT support in SoftDevice handler. + * @{ + * @ingroup app_common + * @brief This file contains the declarations of types required for ANT stack support. These + * types will be defined when the preprocessor define ANT_STACK_SUPPORT_REQD is defined. + */ + +#ifndef ANT_STACK_HANDLER_TYPES_H__ +#define ANT_STACK_HANDLER_TYPES_H__ + +#ifdef ANT_STACK_SUPPORT_REQD + +#include +#include "nordic_global.h" + +#define ANT_STACK_EVT_MSG_BUF_SIZE 32 /**< Size of ANT event message buffer. This will be provided to the SoftDevice while fetching an event. */ +#define ANT_STACK_EVT_STRUCT_SIZE (sizeof(ant_evt_t)) /**< Size of the @ref ant_evt_t structure. This will be used by the @ref softdevice_handler.h to internal event buffer size needed. */ + +/**@brief ANT stack event type. */ +typedef struct +{ + uint8_t channel; /**< Channel number. */ + uint8_t event; /**< Event code. */ + uint8_t evt_buffer[ANT_STACK_EVT_MSG_BUF_SIZE]; /**< Event message buffer. */ +} ant_evt_t; + +/**@brief Application ANT stack event handler type. */ +typedef void (*ant_evt_handler_t) (ant_evt_t * p_ant_evt); + +/**@brief Function for registering for ANT events. + * + * @details The application should use this function to register for receiving ANT events from + * the SoftDevice. If the application does not call this function, then any ANT event + * that may be generated by the SoftDevice will NOT be fetched. Once the application has + * registered for the events, it is not possible to possible to cancel the registration. + * However, it is possible to register a different function for handling the events at + * any point of time. + * + * @param[in] ant_evt_handler Function to be called for each received ANT event. + * + * @retval NRF_SUCCESS Successful registration. + * @retval NRF_ERROR_NULL Null pointer provided as input. + */ +uint32_t softdevice_ant_evt_handler_set(ant_evt_handler_t ant_evt_handler); + +#else + +// The ANT Stack support is not required. + +#define ANT_STACK_EVT_STRUCT_SIZE 0 /**< Since the ANT stack support is not required, this is equated to 0, so that the @ref softdevice_handler.h can compute the internal event buffer size without having to care for ANT events.*/ + +#endif // ANT_STACK_SUPPORT_REQD + +#endif // ANT_STACK_HANDLER_TYPES_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/ble_stack_handler_types.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/ble_stack_handler_types.h new file mode 100644 index 0000000000..2f4824b306 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/ble_stack_handler_types.h @@ -0,0 +1,67 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/**@file + * + * @defgroup ble_stack_handler_types Types definitions for BLE support in SoftDevice handler. + * @{ + * @ingroup app_common + * @brief This file contains the declarations of types required for BLE stack support. These + * types will be defined when the preprocessor define BLE_STACK_SUPPORT_REQD is defined. + */ + +#ifndef BLE_STACK_HANDLER_TYPES_H__ +#define BLE_STACK_HANDLER_TYPES_H__ + +#include "nordic_global.h" + +#ifdef BLE_STACK_SUPPORT_REQD + +#include +#include "ble.h" +#include "nrf_sdm.h" +#include "app_error.h" +#include "app_scheduler.h" +#include "app_util.h" + +#define BLE_STACK_EVT_MSG_BUF_SIZE (sizeof(ble_evt_t) + (GATT_MTU_SIZE_DEFAULT)) /**< Size of BLE event message buffer. This will be provided to the SoftDevice while fetching an event. */ +#define BLE_STACK_HANDLER_SCHED_EVT_SIZE 0 /**< The size of the scheduler event used by SoftDevice handler when passing BLE events using the @ref app_scheduler. */ + +/**@brief Application stack event handler type. */ +typedef void (*ble_evt_handler_t) (ble_evt_t * p_ble_evt); + +/**@brief Function for registering for BLE events. + * + * @details The application should use this function to register for receiving BLE events from + * the SoftDevice. If the application does not call this function, then any BLE event + * that may be generated by the SoftDevice will NOT be fetched. Once the application has + * registered for the events, it is not possible to possible to cancel the registration. + * However, it is possible to register a different function for handling the events at + * any point of time. + * + * @param[in] ble_evt_handler Function to be called for each received BLE event. + * + * @retval NRF_SUCCESS Successful registration. + * @retval NRF_ERROR_NULL Null pointer provided as input. + */ +uint32_t softdevice_ble_evt_handler_set(ble_evt_handler_t ble_evt_handler); + +#else + +#define BLE_STACK_EVT_MSG_BUF_SIZE 0 /**< Since the BLE stack support is not required, this is equated to 0, so that the @ref softdevice_handler.h can compute the internal event buffer size without having to care for BLE events.*/ +#define BLE_STACK_HANDLER_SCHED_EVT_SIZE 0 + +#endif // BLE_STACK_SUPPORT_REQD + +#endif // BLE_STACK_HANDLER_TYPES_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/softdevice_handler.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/softdevice_handler.h new file mode 100644 index 0000000000..c73d4785cb --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/sd_common/softdevice_handler.h @@ -0,0 +1,165 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +/** @file + * + * @defgroup softdevice_handler SoftDevice Event Handler + * @{ + * @ingroup app_common + * @brief API for initializing and disabling the SoftDevice + * + * @details This API contains the functions and defines exposed by the @ref lib_softdevice_handler. + * For more information on the library and how the application should use it, please refer + * @ref lib_softdevice_handler. + * + * @note Use the USE_SCHEDULER parameter of the SOFTDEVICE_HANDLER_INIT() macro to select if + * the @ref app_scheduler is to be used or not. + * + * @note Even if the scheduler is not used, softdevice_handler.h will include app_scheduler.h. + * So when compiling, app_scheduler.h must be available in one of the compiler include + * paths. + */ + +#ifndef SOFTDEVICE_HANDLER_H__ +#define SOFTDEVICE_HANDLER_H__ + +#include +#include "nordic_global.h" +#include "nrf_sdm.h" +#include "app_error.h" +#include "app_scheduler.h" +#include "app_util.h" +#include "ble_stack_handler_types.h" +#include "ant_stack_handler_types.h" + +#define SOFTDEVICE_SCHED_EVT_SIZE 0 /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). For SoftDevice events, this size is 0, since the events are being pulled in the event handler. */ +#define SYS_EVT_MSG_BUF_SIZE sizeof(uint32_t) /**< Size of System (SOC) event message buffer. */ + +/**@brief Type of function for passing events from the stack handler module to the scheduler. */ +typedef uint32_t (*softdevice_evt_schedule_func_t) (void); + +/**@brief Application System (SOC) event handler type. */ +typedef void (*sys_evt_handler_t) (uint32_t evt_id); + + +/**@brief Macro for initializing the stack event handler. + * + * @details It will handle dimensioning and allocation of the memory buffer required for reading + * events from the stack, making sure the buffer is correctly aligned. It will also + * connect the stack event handler to the scheduler (if specified). + * + * @param[in] CLOCK_SOURCE Low frequency clock source and accuracy (type nrf_clock_lfclksrc_t, + * see sd_softdevice_enable() for details). + * @param[in] USE_SCHEDULER TRUE if the application is using the event scheduler, FALSE + * otherwise. + * + * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it + * several times as long as it is from the same location, that is to do a + * reinitialization). + */ +/*lint -emacro(506, SOFTDEVICE_HANDLER_INIT) */ /* Suppress "Constant value Boolean */ +#define SOFTDEVICE_HANDLER_INIT(CLOCK_SOURCE, \ + USE_SCHEDULER) \ + do \ + { \ + static uint32_t EVT_BUFFER[CEIL_DIV(MAX( \ + MAX(BLE_STACK_EVT_MSG_BUF_SIZE, \ + ANT_STACK_EVT_STRUCT_SIZE), \ + SYS_EVT_MSG_BUF_SIZE \ + ), \ + sizeof(uint32_t))]; \ + uint32_t ERR_CODE; \ + ERR_CODE = softdevice_handler_init((CLOCK_SOURCE), \ + EVT_BUFFER, \ + sizeof(EVT_BUFFER), \ + (USE_SCHEDULER) ? softdevice_evt_schedule : NULL); \ + APP_ERROR_CHECK(ERR_CODE); \ + } while (0) + + +/**@brief Function for initializing the stack handler module. + * + * @details Enables the SoftDevice and the stack event interrupt handler. + * + * @note This function must be called before calling any function in the SoftDevice API. + * + * @note Normally initialization should be done using the SOFTDEVICE_HANDLER_INIT() macro, + * as that will both allocate the event buffer, and also align the buffer correctly. + * + * @param[in] clock_source Low frequency clock source to be used by the SoftDevice. + * @param[in] p_evt_buffer Buffer for holding one stack event. Since heap is not being + * used, this buffer must be provided by the application. The + * buffer must be large enough to hold the biggest stack event the + * application is supposed to handle. The buffer must be aligned to + * a 4 byte boundary. This parameter is unused if neither BLE nor + * ANT stack support is required. + * @param[in] evt_buffer_size Size of SoftDevice event buffer. This parameter is unused if + * BLE stack support is not required. + * @param[in] evt_schedule_func Function for passing events to the scheduler. Point to + * ble_ant_stack_evt_schedule() to connect to the scheduler. + * Set to NULL to make the stack handler module call the event + * handler directly from the stack event interrupt handler. + * + * @retval NRF_SUCCESS Successful initialization. + * @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte + * boundary) or NULL. + */ +uint32_t softdevice_handler_init(nrf_clock_lfclksrc_t clock_source, + void * p_evt_buffer, + uint16_t evt_buffer_size, + softdevice_evt_schedule_func_t evt_schedule_func); + + +/**@brief Function for disabling the SoftDevice. + * + * @details This function will disable the SoftDevice. It will also update the internal state + * of this module. + */ +uint32_t softdevice_handler_sd_disable(void); + + +/**@brief Function for registering for System (SOC) events. + * + * @details The application should use this function to register for receiving System (SOC) + * events from the SoftDevice. If the application does not call this function, then any + * System (SOC) events that may be generated by the SoftDevice will NOT be fetched. Once + * the application has registered for the events, it is not possible to possible to + * cancel the registration. However, it is possible to register a different function for + * handling the events at any point of time. + * + * @param[in] sys_evt_handler Function to be called for each received System (SOC) event. + * + * @retval NRF_SUCCESS Successful registration. + * @retval NRF_ERROR_NULL Null pointer provided as input. + */ +uint32_t softdevice_sys_evt_handler_set(sys_evt_handler_t sys_evt_handler); + + +// Functions for connecting the Stack Event Handler to the scheduler: +/**@cond NO_DOXYGEN */ +void intern_softdevice_events_execute(void); + +static __INLINE void softdevice_evt_get(void * p_event_data, uint16_t event_size) +{ + APP_ERROR_CHECK_BOOL(event_size == 0); + intern_softdevice_events_execute(); +} + +static __INLINE uint32_t softdevice_evt_schedule(void) +{ + return app_sched_event_put(NULL, 0, softdevice_evt_get); +} +/**@endcond */ + +#endif // SOFTDEVICE_HANDLER_H__ + +/** @} */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/system_nrf51.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/system_nrf51.h new file mode 100644 index 0000000000..b28bbf71ce --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/nrf-sdk/system_nrf51.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + + +#ifndef SYSTEM_NRF51_H +#define SYSTEM_NRF51_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "nordic_global.h" + + +extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ + +/** + * Initialize the system + * + * @param none + * @return none + * + * @brief Setup the microcontroller system. + * Initialize the System and update the SystemCoreClock variable. + */ +extern void SystemInit (void); + +/** + * Update SystemCoreClock variable + * + * @param none + * @return none + * + * @brief Updates the SystemCoreClock with current core Clock + * retrieved from cpu registers. + */ +extern void SystemCoreClockUpdate (void); + +#ifdef __cplusplus +} +#endif + +#endif /* SYSTEM_NRF51_H */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/pstorage_platform.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/pstorage_platform.h new file mode 100644 index 0000000000..b5fb6f7f59 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/pstorage_platform.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + + /** @cond To make doxygen skip this file */ + +/** @file + * This header contains defines with respect persistent storage that are specific to + * persistent storage implementation and application use case. + */ +#ifndef PSTORAGE_PL_H__ +#define PSTORAGE_PL_H__ + +#include +#include "nordic_global.h" + +#define PSTORAGE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE) /**< Size of one flash page. */ +#define PSTORAGE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */ + +#define PSTORAGE_FLASH_PAGE_END \ + ((NRF_UICR->BOOTLOADERADDR != PSTORAGE_FLASH_EMPTY_MASK) \ + ? (NRF_UICR->BOOTLOADERADDR / PSTORAGE_FLASH_PAGE_SIZE) \ + : NRF_FICR->CODESIZE) + + +#define PSTORAGE_MAX_APPLICATIONS 2 /**< Maximum number of applications that can be registered with the module, configurable based on system requirements. */ +#define PSTORAGE_MIN_BLOCK_SIZE 0x0010 /**< Minimum size of block that can be registered with the module. Should be configured based on system requirements, recommendation is not have this value to be at least size of word. */ + +#define PSTORAGE_DATA_START_ADDR ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_MAX_APPLICATIONS) \ + * PSTORAGE_FLASH_PAGE_SIZE) /**< Start address for persistent data, configurable according to system requirements. */ +#define PSTORAGE_DATA_END_ADDR (PSTORAGE_FLASH_PAGE_END * PSTORAGE_FLASH_PAGE_SIZE) /**< End address for persistent data, configurable according to system requirements. */ + +#define PSTORAGE_MAX_BLOCK_SIZE PSTORAGE_FLASH_PAGE_SIZE /**< Maximum size of block that can be registered with the module. Should be configured based on system requirements. And should be greater than or equal to the minimum size. */ +#define PSTORAGE_CMD_QUEUE_SIZE 30 /**< Maximum number of flash access commands that can be maintained by the module for all applications. Configurable. */ + + +/** Abstracts persistently memory block identifier. */ +typedef uint32_t pstorage_block_t; + +typedef struct +{ + uint32_t module_id; /**< Module ID.*/ + pstorage_block_t block_id; /**< Block ID.*/ +} pstorage_handle_t; + +typedef uint16_t pstorage_size_t; /** Size of length and offset fields. */ + +/**@brief Handles Flash Access Result Events. To be called in the system event dispatcher of the application. */ +void pstorage_sys_event_handler (uint32_t sys_evt); + +#endif // PSTORAGE_PL_H__ + +/** @} */ +/** @endcond */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/softdevice_handler.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/softdevice_handler.cpp new file mode 100644 index 0000000000..928022a101 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/nordic/softdevice_handler.cpp @@ -0,0 +1,313 @@ +/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + * + */ + +#include "softdevice_handler.h" +#include +#include "nordic_common.h" +#include "app_error.h" +#include "app_util.h" +#include "nrf_assert.h" +#include "nrf_soc.h" +#include "mbed.h" + +#if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD) + #include "ant_interface.h" +#elif defined(ANT_STACK_SUPPORT_REQD) + #include "ant_interface.h" +#elif defined(BLE_STACK_SUPPORT_REQD) + #include "ble.h" +#endif + + +static softdevice_evt_schedule_func_t m_evt_schedule_func; /**< Pointer to function for propagating SoftDevice events to the scheduler. */ + +#if defined (BLE_STACK_SUPPORT_REQD) || defined (ANT_STACK_SUPPORT_REQD) +// The following two definition is needed only if ANT or BLE events are needed to be pulled from the stack. +static uint8_t * m_evt_buffer; /**< Buffer for receiving events from the SoftDevice. */ +#endif + +#ifdef BLE_STACK_SUPPORT_REQD +static uint16_t m_ble_evt_buffer_size; /**< Size of BLE event buffer. */ +#endif + +static volatile bool m_softdevice_enabled = false; /**< Variable to indicate whether the SoftDevice is enabled. */ + +#ifdef BLE_STACK_SUPPORT_REQD +static ble_evt_handler_t m_ble_evt_handler; /**< Application event handler for handling BLE events. */ +#endif + +#ifdef ANT_STACK_SUPPORT_REQD +static ant_evt_handler_t m_ant_evt_handler; /**< Application event handler for handling ANT events. */ +#endif + +static sys_evt_handler_t m_sys_evt_handler; /**< Application event handler for handling System (SOC) events. */ + + +/**@brief Callback function for asserts in the SoftDevice. + * + * @details A pointer to this function will be passed to the SoftDevice. This function will be + * called if an ASSERT statement in the SoftDevice fails. + * + * @param[in] pc The value of the program counter when the ASSERT call failed. + * @param[in] line_num Line number of the failing ASSERT call. + * @param[in] file_name File name of the failing ASSERT call. + */ +void softdevice_assertion_handler(uint32_t pc, uint16_t line_num, const uint8_t * file_name) +{ + UNUSED_PARAMETER(pc); + assert_nrf_callback(line_num, file_name); +} + + +void intern_softdevice_events_execute(void) +{ + if (!m_softdevice_enabled) + { + // SoftDevice not enabled. This can be possible if the SoftDevice was enabled by the + // application without using this module's API (i.e softdevice_handler_init) + + return; + } + + bool no_more_soc_evts = (m_sys_evt_handler == NULL); +#ifdef BLE_STACK_SUPPORT_REQD + bool no_more_ble_evts = (m_ble_evt_handler == NULL); +#endif +#ifdef ANT_STACK_SUPPORT_REQD + bool no_more_ant_evts = (m_ant_evt_handler == NULL); +#endif + + for (;;) + { + uint32_t err_code; + + if (!no_more_soc_evts) + { + uint32_t evt_id; + + // Pull event from SOC. + err_code = sd_evt_get(&evt_id); + + if (err_code == NRF_ERROR_NOT_FOUND) + { + no_more_soc_evts = true; + } + else if (err_code != NRF_SUCCESS) + { + APP_ERROR_HANDLER(err_code); + } + else + { + // Call application's SOC event handler. + m_sys_evt_handler(evt_id); + } + } + +#ifdef BLE_STACK_SUPPORT_REQD + // Fetch BLE Events. + if (!no_more_ble_evts) + { + // Pull event from stack + uint16_t evt_len = m_ble_evt_buffer_size; + + err_code = sd_ble_evt_get(m_evt_buffer, &evt_len); + if (err_code == NRF_ERROR_NOT_FOUND) + { + no_more_ble_evts = true; + } + else if (err_code != NRF_SUCCESS) + { + APP_ERROR_HANDLER(err_code); + } + else + { + // Call application's BLE stack event handler. + m_ble_evt_handler((ble_evt_t *)m_evt_buffer); + } + } +#endif + +#ifdef ANT_STACK_SUPPORT_REQD + // Fetch ANT Events. + if (!no_more_ant_evts) + { + // Pull event from stack + err_code = sd_ant_event_get(&((ant_evt_t *)m_evt_buffer)->channel, + &((ant_evt_t *)m_evt_buffer)->event, + ((ant_evt_t *)m_evt_buffer)->evt_buffer); + if (err_code == NRF_ERROR_NOT_FOUND) + { + no_more_ant_evts = true; + } + else if (err_code != NRF_SUCCESS) + { + APP_ERROR_HANDLER(err_code); + } + else + { + // Call application's ANT stack event handler. + m_ant_evt_handler((ant_evt_t *)m_evt_buffer); + } + } +#endif + + if (no_more_soc_evts) + { + // There are no remaining System (SOC) events to be fetched from the SoftDevice. +#if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD) + // Check if there are any remaining BLE and ANT events. + if (no_more_ble_evts && no_more_ant_evts) + { + break; + } +#elif defined(BLE_STACK_SUPPORT_REQD) + // Check if there are any remaining BLE events. + if (no_more_ble_evts) + { + break; + } +#elif defined(ANT_STACK_SUPPORT_REQD) + // Check if there are any remaining ANT events. + if (no_more_ant_evts) + { + break; + } +#else + // No need to check for BLE or ANT events since there is no support for BLE and ANT + // required. + break; +#endif + } + } +} + + +uint32_t softdevice_handler_init(nrf_clock_lfclksrc_t clock_source, + void * p_evt_buffer, + uint16_t evt_buffer_size, + softdevice_evt_schedule_func_t evt_schedule_func) +{ + uint32_t err_code; + + // Save configuration. +#if defined (BLE_STACK_SUPPORT_REQD) || defined (ANT_STACK_SUPPORT_REQD) + // Check that buffer is not NULL. + if (p_evt_buffer == NULL) + { + return NRF_ERROR_INVALID_PARAM; + } + + // Check that buffer is correctly aligned. + if (!is_word_aligned(p_evt_buffer)) + { + return NRF_ERROR_INVALID_PARAM; + } + + m_evt_buffer = (uint8_t *)p_evt_buffer; +#else + // The variable p_evt_buffer is not needed if neither BLE Stack nor ANT stack support is + // required. + UNUSED_PARAMETER(p_evt_buffer); +#endif + +#if defined (BLE_STACK_SUPPORT_REQD) + m_ble_evt_buffer_size = evt_buffer_size; +#else + // The variable evt_buffer_size is not needed if BLE Stack support is NOT required. + UNUSED_PARAMETER(evt_buffer_size); +#endif + + m_evt_schedule_func = evt_schedule_func; + + // Initialize SoftDevice. + + err_code = sd_softdevice_enable(clock_source, softdevice_assertion_handler); + if (err_code != NRF_SUCCESS) + { + return err_code; + } + + m_softdevice_enabled = true; + // Enable BLE event interrupt (interrupt priority has already been set by the stack). + return sd_nvic_EnableIRQ(SWI2_IRQn); +} + + +uint32_t softdevice_handler_sd_disable(void) +{ + uint32_t err_code = sd_softdevice_disable(); + + m_softdevice_enabled = !(err_code == NRF_SUCCESS); + + return err_code; +} + + +#ifdef BLE_STACK_SUPPORT_REQD +uint32_t softdevice_ble_evt_handler_set(ble_evt_handler_t ble_evt_handler) +{ + if (ble_evt_handler == NULL) + { + return NRF_ERROR_NULL; + } + + m_ble_evt_handler = ble_evt_handler; + + return NRF_SUCCESS; +} +#endif + + +#ifdef ANT_STACK_SUPPORT_REQD +uint32_t softdevice_ant_evt_handler_set(ant_evt_handler_t ant_evt_handler) +{ + if (ant_evt_handler == NULL) + { + return NRF_ERROR_NULL; + } + + m_ant_evt_handler = ant_evt_handler; + + return NRF_SUCCESS; +} +#endif + + +uint32_t softdevice_sys_evt_handler_set(sys_evt_handler_t sys_evt_handler) +{ + if (sys_evt_handler == NULL) + { + return NRF_ERROR_NULL; + } + + m_sys_evt_handler = sys_evt_handler; + + return NRF_SUCCESS; +} + + +/**@brief Function for handling the Application's BLE Stack events interrupt. + * + * @details This function is called whenever an event is ready to be pulled. + */ +extern "C" void SWI2_IRQHandler(void) +{ + if (m_evt_schedule_func != NULL) + { + uint32_t err_code = m_evt_schedule_func(); + APP_ERROR_CHECK(err_code); + } + else + { + intern_softdevice_events_execute(); + } +} diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/projectconfig.h b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/projectconfig.h new file mode 100644 index 0000000000..05ac2d72f2 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/BLE_API_Native/hw/nRF51822n/projectconfig.h @@ -0,0 +1,134 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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 _PROJECTCONFIG_H_ +#define _PROJECTCONFIG_H_ + +/*========================================================================= + MCU & BOARD SELCTION + + CFG_BOARD is one of the value defined in board.h + -----------------------------------------------------------------------*/ + #define CFG_BOARD BOARD_PCA10001 + #define CFG_MCU_STRING "nRF51822" +/*=========================================================================*/ + + +/*========================================================================= + CODE BASE VERSION SETTINGS + + Please do not modify this version number. To set a version number + for your project or firmware, change the values in your 'boards/' + config file. + -----------------------------------------------------------------------*/ + #define CFG_CODEBASE_VERSION_MAJOR 0 + #define CFG_CODEBASE_VERSION_MINOR 1 + #define CFG_CODEBASE_VERSION_REVISION 0 +/*=========================================================================*/ + + +/*========================================================================= + FIRMWARE VERSION SETTINGS + -----------------------------------------------------------------------*/ + #define CFG_FIRMWARE_VERSION_MAJOR 0 + #define CFG_FIRMWARE_VERSION_MINOR 0 + #define CFG_FIRMWARE_VERSION_REVISION 0 +/*=========================================================================*/ + + +/*========================================================================= + DEBUG LEVEL + ----------------------------------------------------------------------- + + CFG_DEBUG Level 3: Full debug output, any failed assert + will produce a breakpoint for the + debugger + Level 2: ATTR_ALWAYS_INLINE is null, ASSERT + has text + Level 1: ATTR_ALWAYS_INLINE is an attribute, + ASSERT has no text + Level 0: No debug information generated + + -----------------------------------------------------------------------*/ + #define CFG_DEBUG (2) + + #if (CFG_DEBUG > 3) || (CFG_DEBUG < 0) + #error "CFG_DEBUG must be a value between 0 (no debug) and 3" + #endif +/*=========================================================================*/ + + +/*========================================================================= + GENERAL NRF51 PERIPHERAL SETTINGS + ----------------------------------------------------------------------- + + CFG_SCHEDULER_ENABLE Set this to 'true' or 'false' depending on + if you use the event scheduler or not + + -----------------------------------------------------------------------*/ + #define CFG_SCHEDULER_ENABLE false + + /*------------------------------- GPIOTE ------------------------------*/ + #define CFG_GPIOTE_MAX_USERS 1 /**< Maximum number of users of the GPIOTE handler. */ + + /*-------------------------------- TIMER ------------------------------*/ + #define CFG_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. freq = (32768/(PRESCALER+1)) */ + #define CFG_TIMER_MAX_INSTANCE 8 /**< Maximum number of simultaneously created timers. */ + #define CFG_TIMER_OPERATION_QUEUE_SIZE 5 /**< Size of timer operation queues. */ +/*=========================================================================*/ + + +/*========================================================================= + BTLE SETTINGS + -----------------------------------------------------------------------*/ + + #define CFG_BLE_TX_POWER_LEVEL 4 /**< in dBm (Valid values are -40, -20, -16, -12, -8, -4, 0, 4) */ + + /*---------------------------- BOND MANAGER ---------------------------*/ + #define CFG_BLE_BOND_FLASH_PAGE_BOND (BLE_FLASH_PAGE_END-1) /**< Flash page used for bond manager bonding information.*/ + #define CFG_BLE_BOND_FLASH_PAGE_SYS_ATTR (BLE_FLASH_PAGE_END-3) /**< Flash page used for bond manager system attribute information. TODO check if we can use BLE_FLASH_PAGE_END-2*/ + #define CFG_BLE_BOND_DELETE_BUTTON_NUM 0 /**< Button to press to delete bond details during init */ + + /*------------------------------ SECURITY -----------------------------*/ + #define CFG_BLE_SEC_PARAM_MITM 0 /**< Man In The Middle protection not required. */ + #define CFG_BLE_SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /**< No I/O capabilities. */ + #define CFG_BLE_SEC_PARAM_OOB 0 /**< Out Of Band data not available. */ + #define CFG_BLE_SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */ + #define CFG_BLE_SEC_PARAM_MAX_KEY_SIZE 16 + + /*--------------------------------- GAP -------------------------------*/ + #define CFG_GAP_APPEARANCE BLE_APPEARANCE_GENERIC_TAG + #define CFG_GAP_LOCAL_NAME "nRF5x" + + #define CFG_GAP_CONNECTION_MIN_INTERVAL_MS 500 /**< Minimum acceptable connection interval */ + #define CFG_GAP_CONNECTION_MAX_INTERVAL_MS 1000 /**< Maximum acceptable connection interval */ + #define CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS 4000 /**< Connection supervisory timeout */ + #define CFG_GAP_CONNECTION_SLAVE_LATENCY 0 /**< Slave Latency in number of connection events. */ + + #define CFG_GAP_ADV_INTERVAL_MS 25 /**< The advertising interval in miliseconds, should be multiply of 0.625 */ + #define CFG_GAP_ADV_TIMEOUT_S 180 /**< The advertising timeout in units of seconds. */ +/*=========================================================================*/ + + +/*========================================================================= + VALIDATION + -----------------------------------------------------------------------*/ + #if CFG_BLE_TX_POWER_LEVEL != -40 && CFG_BLE_TX_POWER_LEVEL != -20 && CFG_BLE_TX_POWER_LEVEL != -16 && CFG_BLE_TX_POWER_LEVEL != -12 && CFG_BLE_TX_POWER_LEVEL != -8 && CFG_BLE_TX_POWER_LEVEL != -4 && CFG_BLE_TX_POWER_LEVEL != 0 && CFG_BLE_TX_POWER_LEVEL != 4 + #error "CFG_BLE_TX_POWER_LEVEL must be -40, -20, -16, -12, -8, -4, 0 or 4" + #endif +/*=========================================================================*/ + +#endif /* _PROJECTCONFIG_H_ */ diff --git a/libraries/tests/nordic/BLE_Health_Thermometer_full/main.cpp b/libraries/tests/nordic/BLE_Health_Thermometer_full/main.cpp new file mode 100644 index 0000000000..7f49815e58 --- /dev/null +++ b/libraries/tests/nordic/BLE_Health_Thermometer_full/main.cpp @@ -0,0 +1,218 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed 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. + */ + +#include "mbed.h" +#include "nRF51822n.h" +#include "TMP102.h" + +nRF51822n nrf; /* BLE radio driver */ + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +Serial pc(USBTX,USBRX); +TMP102 healthThemometer(p22, p20, 0x90); + +/* Device Information service */ +uint8_t manufacturerName[4] = { 'm', 'b', 'e', 'd' }; +GattService deviceInformationService ( GattService::UUID_DEVICE_INFORMATION_SERVICE ); +GattCharacteristic deviceManufacturer ( GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR, + sizeof(manufacturerName), sizeof(manufacturerName), + GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ); + +/* Battery Level Service */ +uint8_t batt = 100; /* Battery level */ +uint8_t read_batt = 0; /* Variable to hold battery level reads */ +GattService battService ( GattService::UUID_BATTERY_SERVICE ); +GattCharacteristic battLevel ( GattCharacteristic::UUID_BATTERY_LEVEL_CHAR, 1, 1, + GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | + GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ); + + +/* Health Thermometer Service */ +uint8_t thermTempPayload[5] = { 0, 0, 0, 0, 0 }; +GattService thermService (GattService::UUID_HEALTH_THERMOMETER_SERVICE); +GattCharacteristic thermTemp (GattCharacteristic::UUID_TEMPERATURE_MEASUREMENT_CHAR, + 5, 5, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE); + +/* Advertising data and parameters */ +GapAdvertisingData advData; +GapAdvertisingData scanResponse; +GapAdvertisingParams advParams ( GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED ); +uint16_t uuid16_list[] = { GattService::UUID_BATTERY_SERVICE, + GattService::UUID_DEVICE_INFORMATION_SERVICE, + GattService::UUID_HEALTH_THERMOMETER_SERVICE }; + +uint32_t quick_ieee11073_from_float(float temperature); +void updateServiceValues(void); + +/**************************************************************************/ +/*! + @brief This custom class can be used to override any GapEvents + that you are interested in handling on an application level. +*/ +/**************************************************************************/ +class GapEventHandler : public GapEvents +{ + virtual void onTimeout(void) + { + pc.printf("Advertising Timeout!\n\r"); + // Restart the advertising process with a much slower interval, + // only start advertising again after a button press, etc. + } + + virtual void onConnected(void) + { + pc.printf("Connected!\n\r"); + } + + virtual void onDisconnected(void) + { + pc.printf("Disconnected!\n\r"); + pc.printf("Restarting the advertising process\n\r"); + nrf.getGap().startAdvertising(advParams); + } +}; + +/**************************************************************************/ +/*! + @brief This custom class can be used to override any GattServerEvents + that you are interested in handling on an application level. +*/ +/**************************************************************************/ +class GattServerEventHandler : public GattServerEvents +{ + //virtual void onDataSent(void) {} + //virtual void onDataWritten(void) {} + + virtual void onUpdatesEnabled(uint16_t charHandle) + { + if (charHandle == thermTemp.handle) + { + pc.printf("Temperature indication enabled\n\r"); + } + } + + virtual void onUpdatesDisabled(uint16_t charHandle) + { + if (charHandle == thermTemp.handle) + { + pc.printf("Temperature indication disabled\n\r"); + } + } + + virtual void onConfirmationReceived(uint16_t charHandle) + { + if (charHandle == thermTemp.handle) + { + pc.printf("Temperature indication received\n\r"); + } + } +}; + +/**************************************************************************/ +/*! + @brief Program entry point +*/ +/**************************************************************************/ +int main(void) +{ + pc.baud(115200); + + /* Setup blinky: led1 is toggled in main, led2 is toggled via Ticker */ + led1=1; + led2=1; + + /* Setup the local GAP/GATT event handlers */ + nrf.getGap().setEventHandler(new GapEventHandler()); + nrf.getGattServer().setEventHandler(new GattServerEventHandler()); + + /* Initialise the nRF51822 */ + pc.printf("Initialising the nRF51822\n\r"); + nrf.init(); + + /* Make sure we get a clean start */ + nrf.reset(); + + /* Add BLE-Only flag and complete service list to the advertising data */ + advData.addFlags(GapAdvertisingData::BREDR_NOT_SUPPORTED); + advData.addData(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, + (uint8_t*)uuid16_list, sizeof(uuid16_list)); + advData.addAppearance(GapAdvertisingData::GENERIC_THERMOMETER); + nrf.getGap().setAdvertisingData(advData, scanResponse); + + /* Add the Battery Level service */ + battService.addCharacteristic(battLevel); + nrf.getGattServer().addService(battService); + + /* Add the Device Information service */ + deviceInformationService.addCharacteristic(deviceManufacturer); + nrf.getGattServer().addService(deviceInformationService); + + + /* Health Thermometer Service */ + thermService.addCharacteristic(thermTemp); + nrf.getGattServer().addService(thermService); + + /* Start advertising (make sure you've added all your data first) */ + nrf.getGap().startAdvertising(advParams); + + /* Now that we're live, update the battery level characteristic, and */ + /* change the device manufacturer characteristic to 'mbed' */ + nrf.getGattServer().updateValue(battLevel.handle, (uint8_t*)&batt, sizeof(batt)); + nrf.getGattServer().updateValue(deviceManufacturer.handle, manufacturerName, sizeof(manufacturerName)); + nrf.getGattServer().updateValue(thermTemp.handle, thermTempPayload, sizeof(thermTempPayload)); + + + for (;;) + { + wait(1); + updateServiceValues(); + } +} + +/**************************************************************************/ +/*! + @brief Ticker callback to switch led2 state +*/ +/**************************************************************************/ +void updateServiceValues(void) +{ + /* Toggle the LED */ + led1 = !led1; + + /* Update battery level */ + nrf.getGattServer().updateValue(battLevel.handle, (uint8_t*)&batt, sizeof(batt)); + + /* Update the temperature */ + float temperature = healthThemometer.read(); + uint32_t temp_ieee11073 = quick_ieee11073_from_float(temperature); + memcpy(thermTempPayload+1, &temp_ieee11073, 4); + nrf.getGattServer().updateValue(thermTemp.handle, thermTempPayload, sizeof(thermTempPayload)); + printf("Temperature: %f Celsius\r\n", temperature); +} + +/** + * @brief A very quick conversion between a float temperature and 11073-20601 FLOAT-Type. + * @param temperature The temperature as a float. + * @return The temperature in 11073-20601 FLOAT-Type format. + */ +uint32_t quick_ieee11073_from_float(float temperature) +{ + uint8_t exponent = 0xFF; //exponent is -1 + uint32_t mantissa = (uint32_t)(temperature*10); + + return ( ((uint32_t)exponent) << 24) | mantissa; +} diff --git a/workspace_tools/build_release.py b/workspace_tools/build_release.py index cb9fef9542..7ad8e3aa06 100644 --- a/workspace_tools/build_release.py +++ b/workspace_tools/build_release.py @@ -26,15 +26,16 @@ from workspace_tools.build_api import build_mbed_libs from workspace_tools.targets import TARGET_MAP OFFICIAL_MBED_LIBRARY_BUILD = ( - ('LPC11U24', ('ARM', 'uARM')), + ('LPC11U24', ('ARM', 'uARM', 'GCC_ARM')), ('LPC1768', ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')), ('UBLOX_C027', ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')), ('LPC2368', ('ARM',)), ('LPC812', ('uARM',)), ('LPC1347', ('ARM',)), ('LPC4088', ('ARM', 'GCC_ARM', 'GCC_CR')), - ('LPC1114', ('uARM',)), + ('LPC1114', ('uARM','GCC_ARM')), ('LPC11U35_401', ('ARM', 'uARM')), + ('LPC11U35_501', ('ARM', 'uARM')), ('LPC1549', ('uARM',)), ('KL05Z', ('ARM', 'uARM', 'GCC_ARM')), @@ -46,7 +47,7 @@ OFFICIAL_MBED_LIBRARY_BUILD = ( ('NUCLEO_F401RE', ('ARM', 'uARM')), ('NUCLEO_F030R8', ('ARM', 'uARM')), - # ('NRF51822', ('ARM', )), + ('NRF51822', ('ARM', )), ) diff --git a/workspace_tools/buildbot/master.cfg b/workspace_tools/buildbot/master.cfg new file mode 100644 index 0000000000..e07c3551cf --- /dev/null +++ b/workspace_tools/buildbot/master.cfg @@ -0,0 +1,406 @@ +# -*- python -*- +# ex: set syntax=python: + +# This is a sample buildmaster config file. It must be installed as +# 'master.cfg' in your buildmaster's base directory. + +# This is the dictionary that the buildmaster pays attention to. We also use +# a shorter alias to save typing. +c = BuildmasterConfig = {} + +####### BUILDSLAVES + +# The 'slaves' list defines the set of recognized buildslaves. Each element is +# a BuildSlave object, specifying a unique slave name and password. The same +# slave name and password must be configured on the slave. +from buildbot.buildslave import BuildSlave +c['slaves'] = [BuildSlave("example-slave", "pass"), + BuildSlave("example-slave-2", "pass"), + BuildSlave("example-slave-KL25Z", "pass"), + BuildSlave("example-slave-LPC1768", "pass"), + BuildSlave("example-slave-LPC11U24", "pass"), + ] + +# 'slavePortnum' defines the TCP port to listen on for connections from slaves. +# This must match the value configured into the buildslaves (with their +# --master option) +c['slavePortnum'] = 9989 + +####### OFFICIAL_MBED_LIBRARY_BUILD + +OFFICIAL_MBED_LIBRARY_BUILD = ( + ('LPC1768', ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')), + ('KL05Z', ('ARM', 'uARM', 'GCC_ARM')), + ('KL25Z', ('ARM', 'GCC_ARM')), + ('LPC11U24', ('ARM', 'uARM')), + ('KL46Z', ('ARM', 'GCC_ARM')), + ('LPC4088', ('ARM', 'GCC_ARM', 'GCC_CR')), + ('LPC1347', ('ARM',)), + ('LPC1549', ('uARM',)), + ('LPC2368', ('ARM',)), + ('LPC812', ('uARM',)), + ('LPC11U35_401', ('ARM', 'uARM')), + ('LPC1114', ('uARM',)), + ('NUCLEO_F103RB', ('ARM', 'uARM')), + ('NUCLEO_L152RE', ('ARM', 'uARM')), + ('NUCLEO_F401RE', ('ARM', 'uARM')), + ('NUCLEO_F030R8', ('ARM', 'uARM')), + ('UBLOX_C027', ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')), + # ('NRF51822', ('ARM',)), +) + +# Which hardware platforms are supported for target testing +OFFICIAL_MBED_TESTBED_SUPPORTED_HARDWARE = ( + # 'KL25Z', + # 'LPC1768', + # 'LPC11U24', +) + +####### CHANGESOURCES + +# the 'change_source' setting tells the buildmaster how it should find out +# about source code changes. Here we point to the buildbot clone of pyflakes. + +from buildbot.changes.gitpoller import GitPoller +c['change_source'] = [] +""" +c['change_source'].append(GitPoller( + 'git://github.com/buildbot/pyflakes.git', + workdir='gitpoller-workdir', branch='master', + pollinterval=300)) +""" +####### SCHEDULERS + +# Configure the Schedulers, which decide how to react to incoming changes. In this +# case, just kick off a 'runtests' build + +from buildbot.schedulers.basic import SingleBranchScheduler +from buildbot.schedulers.forcesched import ForceScheduler +from buildbot.changes import filter +c['schedulers'] = [] + +# Create builders to generate one target using all assigned toolchains +release_builder_name = "BuildRelease" +builder_names = [release_builder_name] +for target_name, toolchains in OFFICIAL_MBED_LIBRARY_BUILD: + builder_name = "All_TC_%s" % target_name + builder_names.append(builder_name) +c['schedulers'].append(ForceScheduler(name="force", builderNames=builder_names)) + +####### BUILDERS + +# The 'builders' list defines the Builders, which tell Buildbot how to perform a build: +# what steps, and which slaves can execute them. Note that any particular build will +# only take place on one slave. + +from buildbot.process.factory import BuildFactory +from buildbot.steps.source.git import Git +from buildbot.steps.shell import ShellCommand +from buildbot.process.buildstep import LogLineObserver +import buildbot.status.results +import re +import pprint + +class TestCommand(ShellCommand): + failedTestsCount = 0 # FAIL + passedTestsCount = 0 # OK + errorsTestsCount = 0 # ERROR + undefsTestsCount = 0 # UNDEF + testsResults = [] + + def __init__(self, stage=None,module=None, moduleset=None, **kwargs): + ShellCommand.__init__(self, **kwargs) + self.failedTestsCount = 0 + self.passedTestsCount = 0 + self.errorsTestsCount = 0 + self.tracebackPyCount = 0 + self.testsResults = [] + testFailuresObserver = UnitTestsObserver () + self.addLogObserver('stdio', testFailuresObserver) + + def createSummary(self, log): + if self.failedTestsCount >= 0 or self.passedTestsCount >= 0 or self.errorsTestsCount >= 0 or self.undefsTestsCount >= 0: + self.addHTMLLog ('tests summary', self.createTestsSummary()) + + def getText(self, cmd, results): + text = ShellCommand.getText(self, cmd, results) + text.append("OK: " + str(self.passedTestsCount)) + text.append("FAIL: " + str(self.failedTestsCount)) + text.append("ERROR: " + str(self.errorsTestsCount)) + text.append("UNDEF: " + str(self.undefsTestsCount)) + text.append("Traceback: " + str(self.tracebackPyCount)) + return text + + def evaluateCommand(self, cmd): + if self.failedTestsCount > 0: + return buildbot.status.results.WARNINGS + elif self.errorsTestsCount > 0 or self.undefsTestsCount > 0 or self.tracebackPyCount > 0: + return buildbot.status.results.FAILURE + return buildbot.status.results.SUCCESS + + def find_unique_tc_result_value(self, index): + """ Get unique values from each row in data parameter """ + result = [] + for tc_result_list in self.testsResults: + if tc_result_list[index] not in result: + result.append(tc_result_list[index]) + return result + + def html_view_test_result(self, targets, tests, toolchain): + """ Generates simple result table """ + COLOR_OK = "LimeGreen" + COLOR_FAIL = "LightCoral" + COLOR_UNDEF = "LightSlateGray" + COLOR_NEUTRAL = "Silver" + + STATUS_COLORS = { "OK" : COLOR_OK, + "FAIL" : COLOR_FAIL, + "UNDEF" : COLOR_UNDEF} + + result = "" + result += "" + for test in tests: + result += "" + result += "" + + for target in targets: + result += "" + for test in tests: + for tc_result_list in self.testsResults: + if tc_result_list[1] == target and tc_result_list[2] == toolchain and tc_result_list[3] == test: + status = tc_result_list[4] + bgcolor = STATUS_COLORS[status] + result += "" + break; + else: + result += "" + result += "" + result += "
" + toolchain + "" + test + "

" + target + "
" + status + "
" + return result + + def createTestsSummary (self): + targets = self.find_unique_tc_result_value(1) + toolchains = self.find_unique_tc_result_value(2) + tests = self.find_unique_tc_result_value(3) + html_result = "" + for toolchain in toolchains: + html_result += self.html_view_test_result(targets, tests, toolchain) + html_result += "
" + return html_result + + +class UnitTestsObserver(LogLineObserver): + reGroupTestResult = [] + reGroupPyResult = [] + + def __init__(self): + LogLineObserver.__init__(self) + if len(self.reGroupTestResult) == 0: + self.reGroupTestResult.append(re.compile("^(\w+Test)::(\w+)::(\w+)::(\w+)::.* \[(\w+)\] in (\d+\.\d+) of (\d+) sec[\r\n]*$")) + + def outLineReceived(self, line): + matched = False + for r in self.reGroupTestResult: + result = r.match(line) + if result: + self.step.testsResults.append(result.groups()) + if result.group(5) == 'OK': + self.step.passedTestsCount += 1 + elif result.group(5) == 'FAIL': + self.step.failedTestsCount += 1 + elif result.group(5) == 'UNDEF': + self.step.undefsTestsCount += 1 + elif result.group(5) == 'ERROR': + self.step.errorsTestsCount += 1 + matched = True + + +class BuildCommand(ShellCommand): + warningsCount = 0 # [Warning] + errorsCount = 0 # [Error] + testsResults = [] + + def __init__(self, stage=None,module=None, moduleset=None, **kwargs): + ShellCommand.__init__(self, **kwargs) + self.warningsCount = 0 + self.errorsCount = 0 + self.testsResults = [] + buildProcessObserver = BuildObserver () + self.addLogObserver('stdio', buildProcessObserver) + + def createSummary(self, log): + if self.warningsCount >= 0 or self.errorsCount >= 0: + self.addHTMLLog ('tests summary', self.createTestsSummary()) + + def getText(self, cmd, results): + text = ShellCommand.getText(self, cmd, results) + if self.warningsCount > 0 or self.errorsCount > 0: + text.append("warnings: " + str(self.warningsCount)) + text.append("errors: " + str(self.errorsCount)) + return text + + def evaluateCommand(self, cmd): + if self.warningsCount > 0: + return buildbot.status.results.WARNINGS + elif self.errorsCount > 0: + return buildbot.status.results.FAILURE + else: + return buildbot.status.results.SUCCESS + + def createTestsSummary (self): + # Create a string with your html report and return it + html = "

Report

" + #for result in self.testsResults: + html += "
" + return html + +class BuildObserver(LogLineObserver): + regroupresult = [] + + def __init__(self): + LogLineObserver.__init__(self) + if len(self.regroupresult) == 0: + self.regroupresult.append(re.compile("^\[([Ww]arning)\] (.*)")) + self.regroupresult.append(re.compile("^\[([Ee]rror)\] (.*)")) + + def outLineReceived(self, line): + matched = False + for r in self.regroupresult: + result = r.match(line) + if result: + self.step.testsResults.append(result.groups()) + if result.group(1) == 'Warning': + self.step.warningsCount += 1 + elif result.group(1) == 'Error': + self.step.errorsCount += 1 + matched = True + #if not matched: + # [Future-Dev] Other check... + + +####### BUILDERS - mbed project +git_clone = Git(repourl='https://github.com/mbedmicro/mbed.git', mode='incremental') + +# create the build factory for mbed and add the steps to it +from buildbot.config import BuilderConfig + +c['builders'] = [] + +copy_private_settings = ShellCommand(name = "copy private_settings.py", + command = "cp ../private_settings.py workspace_tools/private_settings.py", + haltOnFailure = True, + description = "Copy private_settings.py") + +mbed_build_release = BuildFactory() +mbed_build_release.addStep(git_clone) +mbed_build_release.addStep(copy_private_settings) + +for target_name, toolchains in OFFICIAL_MBED_LIBRARY_BUILD: + builder_name = "All_TC_%s" % target_name + mbed_build = BuildFactory() + mbed_build.addStep(git_clone) + mbed_build.addStep(copy_private_settings) + # Adding all chains for target + for toolchain in toolchains: + build_py = BuildCommand(name = "Build %s using %s" % (target_name, toolchain), + command = "python workspace_tools/build.py -m %s -t %s" % (target_name, toolchain), + haltOnFailure = True, + warnOnWarnings = True, + description = "Building %s using %s" % (target_name, toolchain), + descriptionDone = "Built %s using %s" % (target_name, toolchain)) + + mbed_build.addStep(build_py) + mbed_build_release.addStep(build_py) # For build release we need all toolchains + + if target_name in OFFICIAL_MBED_TESTBED_SUPPORTED_HARDWARE: + copy_example_test_spec_json = ShellCommand(name = "Copy example_test_spec.json", + command = "cp ../example_test_spec.json workspace_tools/data/example_test_spec.json", + haltOnFailure = True, + description = "Copy example_test_spec.json") + + autotest_py = ShellCommand(name = "Running autotest.py for %s" % (target_name), + command = "python workspace_tools/autotest.py workspace_tools/data/example_test_spec.json", + haltOnFailure = True, + description = "Running autotest.py") + + mbed_build.addStep(copy_example_test_spec_json) + mbed_build.addStep(autotest_py) + + # Add builder with steps for each toolchain + c['builders'].append(BuilderConfig(name=builder_name, + slavenames=["example-slave-%s" % (target_name)], + factory=mbed_build)) + else: + # Add builder with steps for each toolchain + c['builders'].append(BuilderConfig(name=builder_name, + slavenames=["example-slave"], + factory=mbed_build)) + +# copy_example_test_spec_json = ShellCommand(name = "Copy example_test_spec.json", + # command = "cp ../example_test_spec.json workspace_tools/data/example_test_spec.json", + # haltOnFailure = True, + # description = "Copy example_test_spec.json") + +singletest_py = TestCommand(name = "Running Target Tests", + command = "python workspace_tools/singletest.py -i workspace_tools/test_spec.json -M workspace_tools/muts_all.json", + haltOnFailure = True, + warnOnWarnings = True, + description = "Running Target Tests", + descriptionDone = "Target Testing Finished") + +mbed_build_release.addStep(singletest_py) +# Release build collects all building toolchains +c['builders'].append(BuilderConfig(name=release_builder_name, + slavenames=["example-slave"], + factory=mbed_build_release)) + +####### STATUS TARGETS + +# 'status' is a list of Status Targets. The results of each build will be +# pushed to these targets. buildbot/status/*.py has a variety to choose from, +# including web pages, email senders, and IRC bots. + +c['status'] = [] + +from buildbot.status import html +from buildbot.status.web import authz, auth + +authz_cfg=authz.Authz( + # change any of these to True to enable; see the manual for more + # options + auth=auth.BasicAuth([("pyflakes","pyflakes")]), + gracefulShutdown = False, + forceBuild = 'auth', # use this to test your slave once it is set up + forceAllBuilds = True, + pingBuilder = True, + stopBuild = True, + stopAllBuilds = True, + cancelPendingBuild = True, +) +c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg, order_console_by_time=True)) + +####### PROJECT IDENTITY + +# the 'title' string will appear at the top of this buildbot +# installation's html.WebStatus home page (linked to the +# 'titleURL') and is embedded in the title of the waterfall HTML page. + +c['title'] = "Green Tea" +c['titleURL'] = "" + +# the 'buildbotURL' string should point to the location where the buildbot's +# internal web server (usually the html.WebStatus page) is visible. This +# typically uses the port number set in the Waterfall 'status' entry, but +# with an externally-visible host name which the buildbot cannot figure out +# without some help. + +c['buildbotURL'] = "http://localhost:8010/" + +####### DB URL + +c['db'] = { + # This specifies what database buildbot uses to store its state. You can leave + # this at its default for all but the largest installations. + 'db_url' : "sqlite:///state.sqlite", + # 'db_url' : "mysql://buildbot:123456@localhost/buildbot_mbed?max_idle=300", +} diff --git a/workspace_tools/export/gcc_arm_lpc1114.tmpl b/workspace_tools/export/gcc_arm_lpc1114.tmpl new file mode 100644 index 0000000000..ac89299a93 --- /dev/null +++ b/workspace_tools/export/gcc_arm_lpc1114.tmpl @@ -0,0 +1,46 @@ +# This file was automagically generated by mbed.org. For more information, +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +GCC_BIN = +PROJECT = {{name}} +OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %} +SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %} +INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} +LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} +LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} +LINKER_SCRIPT = {{linker_script}} + +############################################################################### +AS = $(GCC_BIN)arm-none-eabi-as +CC = $(GCC_BIN)arm-none-eabi-gcc +CPP = $(GCC_BIN)arm-none-eabi-g++ +LD = $(GCC_BIN)arm-none-eabi-gcc +OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy + +CPU = -mcpu=cortex-m0 -mthumb +CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} + +LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs +LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys + +all: $(PROJECT).bin + +clean: + rm -f $(PROJECT).bin $(PROJECT).elf $(OBJECTS) + +.s.o: + $(AS) $(CPU) -o $@ $< + +.c.o: + $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< + +.cpp.o: + $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $< + + +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + +$(PROJECT).bin: $(PROJECT).elf + $(OBJCOPY) -O binary $< $@ diff --git a/workspace_tools/export/gcc_arm_lpc11u24.tmpl b/workspace_tools/export/gcc_arm_lpc11u24.tmpl new file mode 100644 index 0000000000..ac89299a93 --- /dev/null +++ b/workspace_tools/export/gcc_arm_lpc11u24.tmpl @@ -0,0 +1,46 @@ +# This file was automagically generated by mbed.org. For more information, +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +GCC_BIN = +PROJECT = {{name}} +OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %} +SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %} +INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} +LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} +LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} +LINKER_SCRIPT = {{linker_script}} + +############################################################################### +AS = $(GCC_BIN)arm-none-eabi-as +CC = $(GCC_BIN)arm-none-eabi-gcc +CPP = $(GCC_BIN)arm-none-eabi-g++ +LD = $(GCC_BIN)arm-none-eabi-gcc +OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy + +CPU = -mcpu=cortex-m0 -mthumb +CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections +CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} + +LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs +LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys + +all: $(PROJECT).bin + +clean: + rm -f $(PROJECT).bin $(PROJECT).elf $(OBJECTS) + +.s.o: + $(AS) $(CPU) -o $@ $< + +.c.o: + $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< + +.cpp.o: + $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $< + + +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + +$(PROJECT).bin: $(PROJECT).elf + $(OBJCOPY) -O binary $< $@ diff --git a/workspace_tools/export/gccarm.py b/workspace_tools/export/gccarm.py index 179338a0c3..df52ccc90b 100644 --- a/workspace_tools/export/gccarm.py +++ b/workspace_tools/export/gccarm.py @@ -21,7 +21,7 @@ from os.path import splitext, basename class GccArm(Exporter): NAME = 'GccArm' TOOLCHAIN = 'GCC_ARM' - TARGETS = ['LPC1768','KL05Z','KL25Z','KL46Z','K20D5M','LPC4088'] + TARGETS = ['LPC1768','KL05Z','KL25Z','KL46Z','K20D5M','LPC4088','LPC11U24','LPC1114'] DOT_IN_RELATIVE_PATH = True def generate(self): diff --git a/workspace_tools/export/iar.py b/workspace_tools/export/iar.py index 1fd7db8dd2..8803f1d883 100644 --- a/workspace_tools/export/iar.py +++ b/workspace_tools/export/iar.py @@ -19,7 +19,7 @@ from exporters import Exporter class IAREmbeddedWorkbench(Exporter): NAME = 'IAR' - TARGETS = ['LPC1768', 'NUCLEO_F401RE'] + TARGETS = ['LPC1768'] TOOLCHAIN = 'IAR' def generate(self): diff --git a/workspace_tools/export/uvision4.py b/workspace_tools/export/uvision4.py index 453e16088b..f5aa191ed7 100644 --- a/workspace_tools/export/uvision4.py +++ b/workspace_tools/export/uvision4.py @@ -21,9 +21,9 @@ from os.path import basename class Uvision4(Exporter): NAME = 'uVision4' - TARGETS = ['LPC1768', 'LPC11U24', 'KL05Z', 'KL25Z', 'KL46Z', 'K20D5M', 'LPC1347', 'LPC1114', 'LPC11C24', 'LPC4088', 'LPC812', 'NUCLEO_F103RB', 'NUCLEO_L152RE', 'NUCLEO_F030R8', 'NUCLEO_F401RE', 'UBLOX_C027', 'LPC1549'] + TARGETS = ['LPC1768', 'LPC11U24', 'KL05Z', 'KL25Z', 'KL46Z', 'K20D5M', 'LPC1347', 'LPC1114', 'LPC11C24', 'LPC4088', 'LPC812', 'NUCLEO_F103RB', 'NUCLEO_L152RE', 'NUCLEO_F030R8', 'NUCLEO_F401RE', 'UBLOX_C027', 'LPC1549', 'LPC11U35_501'] - USING_MICROLIB = ['LPC11U24', 'LPC1114', 'LPC11C24', 'LPC812', 'NUCLEO_F103RB', 'NUCLEO_L152RE', 'NUCLEO_F030R8', 'NUCLEO_F401RE', 'LPC1549'] + USING_MICROLIB = ['LPC11U24', 'LPC1114', 'LPC11C24', 'LPC812', 'NUCLEO_F103RB', 'NUCLEO_L152RE', 'NUCLEO_F030R8', 'NUCLEO_F401RE', 'LPC1549', 'LPC11U35_501'] FILE_TYPES = { 'c_sources':'1', diff --git a/workspace_tools/export_test.py b/workspace_tools/export_test.py index caafaffddd..8b5f33cf9a 100644 --- a/workspace_tools/export_test.py +++ b/workspace_tools/export_test.py @@ -77,7 +77,7 @@ if __name__ == '__main__': for toolchain, target in [ ('uvision', 'LPC1768'), ('uvision', 'LPC11U24'), ('uvision', 'KL25Z'), ('uvision', 'LPC1347'), ('uvision', 'LPC1114'), ('uvision', 'LPC4088'), - ('uvision', 'NUCLEO_F103RB'), ('uvision', 'NUCLEO_L152RE'), ('uvision', 'NUCLEO_F401RE'), ('uvision', 'NUCLEO_F030R8'), + ('uvision', 'NUCLEO_F103RB'), ('uvision', 'NUCLEO_L152RE'), ('uvision', 'NUCLEO_F401RE'), ('uvision', 'NUCLEO_F030R8'), ('uvision', 'LPC11U35_501'), ('codered', 'LPC1768'), ('codered', 'LPC4088'), @@ -88,6 +88,7 @@ if __name__ == '__main__': # Linux path: /home/emimon01/bin/gcc-arm/bin/ # Windows path: C:/arm-none-eabi-gcc-4_7/bin/ ('gcc_arm', 'LPC1768'), + ('gcc_arm', 'LPC1114'), ('ds5_5', 'LPC1768'), ('ds5_5', 'LPC11U24'), diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py new file mode 100644 index 0000000000..115266148d --- /dev/null +++ b/workspace_tools/singletest.py @@ -0,0 +1,452 @@ +""" +mbed SDK +Copyright (c) 2011-2013 ARM Limited + +Licensed 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. + +Author: Przemyslaw Wirkus + +------------------------------------------------------------------------------- + +Usage: singletest.py [options] + +This script allows you to run mbed defined test cases for particular MCU(s) +and corresponding toolchain(s). + +Options: + -h, --help show this help message and exit + -i FILE, --tests=FILE + Points to file with test specification + -M FILE, --MUTS=FILE Points to file with MUTs specification (overwrites + settings.py and private_settings.py) + -g, --goanna-for-tests + Run Goanna static analyse tool for tests + -G, --goanna-for-sdk Run Goanna static analyse tool for mbed SDK + -s, --suppress-summary + Suppresses display of wellformatted table with test + results + -v, --verbose Verbose mode (pronts some extra information) + +Example: singletest.py -i test_spec.json -M muts_all.json + +------------------------------------------------------------------------------- + +File format example: test_spec.json + +{ + "targets": { + "KL46Z": ["ARM", "GCC_ARM"], + "LPC1768": ["ARM", "GCC_ARM", "GCC_CR", "GCC_CS", "IAR"], + "LPC11U24": ["uARM"], + "NRF51822": ["ARM"] + } +} + +File format example: muts_all.json + +{ + "1" : {"mcu": "LPC1768", + "port":"COM4", "disk":"J:\\", + "peripherals": ["TMP102", "digital_loop", "port_loop", "analog_loop", "SD"] + }, + + "2" : {"mcu": "KL25Z", + "port":"COM7", "disk":"G:\\", + "peripherals": ["digital_loop", "port_loop", "analog_loop"] + } +} + +""" + +import sys +import json +import optparse +import pprint +import re +from prettytable import PrettyTable +from serial import Serial + +from os.path import join, abspath, dirname, exists +from shutil import copy +from subprocess import call +from time import sleep, time + +ROOT = abspath(join(dirname(__file__), "..")) +sys.path.insert(0, ROOT) +# Imports related to mbed build pi +from workspace_tools.build_api import build_project, build_mbed_libs +from workspace_tools.paths import BUILD_DIR +from workspace_tools.targets import TARGET_MAP +from workspace_tools.tests import TEST_MAP + +# Be sure that the tools directory is in the search path +ROOT = abspath(join(dirname(__file__), "..")) +sys.path.insert(0, ROOT) + +# Imports related to mbed build pi +from workspace_tools.utils import delete_dir_files +from workspace_tools.settings import MUTs + + +class SingleTestRunner(object): + """ Object wrapper for single test run which may involve multiple MUTs.""" + + re_detect_testcase_result = None + TEST_RESULT_OK = "OK" + TEST_RESULT_FAIL = "FAIL" + TEST_RESULT_ERROR = "ERROR" + TEST_RESULT_UNDEF = "UNDEF" + + # mbed test suite -> SingleTestRunner + TEST_RESULT_MAPPING = {"success" : TEST_RESULT_OK, + "failure" : TEST_RESULT_FAIL, + "error" : TEST_RESULT_ERROR, + "end" : TEST_RESULT_UNDEF} + + def __init__(self): + pattern = "\\{(" + "|".join(self.TEST_RESULT_MAPPING.keys()) + ")\\}" + self.re_detect_testcase_result = re.compile(pattern) + + def run_host_test(self, target_name, port, + duration, verbose=False): + """ + Functions resets target and grabs by timeouted pooling test log + via serial port. + Function assumes target is already flashed with proper 'test' binary. + """ + output = "" + # Prepare serial for receiving data from target + baud = 9600 + serial = Serial(port, timeout=1) + serial.setBaudrate(baud) + flush_serial(serial) + # Resetting target and pooling + reset(target_name, serial, verbose=verbose) + start_serial_timeour = time() + try: + while (time() - start_serial_timeour) < duration: + test_output = serial.read(512) + output += test_output + flush_serial(serial) + if '{end}' in output: + break + except KeyboardInterrupt, _: + print "CTRL+C break" + flush_serial(serial) + serial.close() + + # Handle verbose mode + if verbose: + print "Test::Output::Start" + print output + print "Test::Output::Finish" + + # Parse test 'output' data + result = self.TEST_RESULT_UNDEF + for line in output.splitlines(): + search_result = self.re_detect_testcase_result.search(line) + if search_result and len(search_result.groups()): + result = self.TEST_RESULT_MAPPING[search_result.groups(0)[0]] + break + return result + + def handle(self, test_spec, target_name, toolchain_name): + """ + Function determines MUT's mbed disk/port and copies binary to + target. Test is being invoked afterwards. + """ + data = json.loads(test_spec) + # Get test information, image and test timeout + test_id = data['test_id'] + test = TEST_MAP[test_id] + test_description = TEST_MAP[test_id].get_description() + image = data["image"] + duration = data.get("duration", 10) + + # Find a suitable MUT: + mut = None + for id, m in MUTs.iteritems(): + if m['mcu'] == data['mcu']: + mut = m + break + + if mut is None: + print "Error: No mbed available: mut[%s]" % data['mcu'] + return + + disk = mut['disk'] + port = mut['port'] + target_by_mcu = TARGET_MAP[mut['mcu']] + + # Program + # When the build and test system were separate, this was relative to a + # base network folder base path: join(NETWORK_BASE_PATH, ) + image_path = image + if not exists(image_path): + print "Error: Image file does not exist: %s" % image_path + elapsed_time = 0 + test_result = "{error}" + return (test_result, target_name, toolchain_name, + test_id, test_description, round(elapsed_time, 2), duration) + + if not target_by_mcu.is_disk_virtual: + delete_dir_files(disk) + + # Program MUT with proper image file + copy(image_path, disk) + + # Copy Extra Files + if not target_by_mcu.is_disk_virtual and test.extra_files: + for f in test.extra_files: + copy(f, disk) + + sleep(target_by_mcu.program_cycle_s()) + + # Host test execution + start_host_exec_time = time() + test_result = self.run_host_test(target_name, port, duration) + elapsed_time = time() - start_host_exec_time + print print_test_result(test_result, target_name, toolchain_name, + test_id, test_description, elapsed_time, duration) + return (test_result, target_name, toolchain_name, + test_id, test_description, round(elapsed_time, 2), duration) + + +def flush_serial(serial): + """ Flushing serial in/out. """ + serial.flushInput() + serial.flushOutput() + + +def reset(mcu_name, serial, verbose=False, sleep_before_reset=0, sleep_after_reset=0): + """ + Functions resets target using various methods (e.g. serial break) + depending on target type. + """ + if sleep_before_reset > 0: + sleep(sleep_before_reset) + if verbose: + verbose_msg = "Reset::cmd(sendBreak)" + # Reset type decision + if mcu_name.startswith('NUCLEO'): # ST NUCLEO + call(["ST-LINK_CLI.exe", "-Rst"]) + verbose_msg = "Reset::cmd(ST-LINK_CLI.exe)" + else: + serial.sendBreak() + + if sleep_before_reset > 0: + sleep(sleep_after_reset) + if verbose: + print verbose_msg + + +def is_peripherals_available(target_mcu_name, peripherals=None): + """ Checks if specified target should run specific peripheral test case.""" + if peripherals is not None: + peripherals = set(peripherals) + for id, mut in MUTs.iteritems(): + # Target MCU name check + if mut["mcu"] != target_mcu_name: + continue + # Peripherals check + if peripherals is not None: + if 'peripherals' not in mut: + continue + if not peripherals.issubset(set(mut['peripherals'])): + continue + return True + return False + + +def print_test_result(test_result, target_name, toolchain_name, + test_id, test_description, elapsed_time, duration): + """ Use specific convention to print test result and related data.""" + tokens = [] + tokens.append("TargetTest") + tokens.append(target_name) + tokens.append(toolchain_name) + tokens.append(test_id) + tokens.append(test_description) + separator = "::" + time_info = " in %.2f of %d sec" % (round(elapsed_time, 2), duration) + result = separator.join(tokens) + " [" + test_result +"]" + time_info + return result + + +def shape_test_request(mcu, image_path, test_id, duration=10): + """ Function prepares JOSN structure describing test specification.""" + test_spec = { + "mcu": mcu, + "image": image_path, + "duration": duration, + "test_id": test_id, + } + return json.dumps(test_spec) + + +def get_json_data_from_file(json_spec_filename, verbose=False): + """ Loads from file JSON formatted string to data structure """ + result = None + try: + with open(json_spec_filename) as data_file: + try: + result = json.load(data_file) + except ValueError as json_error_msg: + result = None + print "Error: %s" % (json_error_msg) + except IOError as fileopen_error_msg: + print "Error: %s" % (fileopen_error_msg) + if verbose and result: + pp = pprint.PrettyPrinter(indent=4) + pp.pprint(result) + return result + + +if __name__ == '__main__': + # Command line options + parser = optparse.OptionParser() + parser.add_option('-i', '--tests', + dest='test_spec_filename', + metavar="FILE", + help='Points to file with test specification') + + parser.add_option('-M', '--MUTS', + dest='muts_spec_filename', + metavar="FILE", + help='Points to file with MUTs specification (overwrites settings.py and private_settings.py)') + + parser.add_option('-g', '--goanna-for-tests', + dest='goanna_for_tests', + metavar=False, + action="store_true", + help='Run Goanna static analyse tool for tests') + + parser.add_option('-G', '--goanna-for-sdk', + dest='goanna_for_mbed_sdk', + metavar=False, + action="store_true", + help='Run Goanna static analyse tool for mbed SDK') + + parser.add_option('-s', '--suppress-summary', + dest='suppress_summary', + default=False, + action="store_true", + help='Suppresses display of wellformatted table with test results') + + parser.add_option('-v', '--verbose', + dest='verbose', + default=False, + action="store_true", + help='Verbose mode (pronts some extra information)') + + parser.description = """This script allows you to run mbed defined test cases for particular MCU(s) and corresponding toolchain(s).""" + parser.epilog = """Example: singletest.py -i test_spec.json [-M muts_all.json]""" + + (opts, args) = parser.parse_args() + + # Open file with test specification + # test_spec_filename tells script which targets and their toolchain(s) + # should be covered by the test scenario + test_spec = get_json_data_from_file(opts.test_spec_filename, opts.verbose) if opts.test_spec_filename else None + if test_spec is None: + parser.print_help() + exit(-1) + + # Get extra MUTs if applicable + if opts.muts_spec_filename: + MUTs = get_json_data_from_file(opts.muts_spec_filename, opts.verbose) + if MUTs is None: + parser.print_help() + exit(-1) + + # Magic happens here... ;) + start = time() + single_test = SingleTestRunner() + + clean = test_spec.get('clean', False) + test_ids = test_spec.get('test_ids', []) + groups = test_spec.get('test_groups', []) + + # Here we store test results + test_summary = [] + + for target, toolchains in test_spec['targets'].iteritems(): + for toolchain in toolchains: + # print '=== %s::%s ===' % (target, toolchain) + # Let's build our test + T = TARGET_MAP[target] + build_mbed_libs_options = ["analyze"] if opts.goanna_for_mbed_sdk else None + build_mbed_libs(T, toolchain, options=build_mbed_libs_options) + build_dir = join(BUILD_DIR, "test", target, toolchain) + + for test_id, test in TEST_MAP.iteritems(): + if test_ids and test_id not in test_ids: + continue + + if test.automated and test.is_supported(target, toolchain): + if not is_peripherals_available(target, test.peripherals): + if opts.verbose: + print "TargetTest::%s::TestSkipped(%s)" % (target, ",".join(test.peripherals)) + continue + + test_result = { + 'target': target, + 'toolchain': toolchain, + 'test_id': test_id, + } + + build_project_options = ["analyze"] if opts.goanna_for_tests else None + path = build_project(test.source_dir, join(build_dir, test_id), + T, toolchain, test.dependencies, options=build_project_options, + clean=clean, verbose=opts.verbose) + + test_result_cache = join(dirname(path), "test_result.json") + + # For an automated test the duration act as a timeout after + # which the test gets interrupted + test_spec = shape_test_request(target, path, test_id, test.duration) + single_test_result = single_test.handle(test_spec, target, toolchain) + test_summary.append(single_test_result) + # print test_spec, target, toolchain + + elapsed_time = time() - start + + # Human readable summary + if not opts.suppress_summary: + result_dict = { single_test.TEST_RESULT_OK : 0, + single_test.TEST_RESULT_FAIL : 0, + single_test.TEST_RESULT_ERROR : 0, + single_test.TEST_RESULT_UNDEF : 0 } + + print + print "Test summary:" + # Pretty table package is used to print results + pt = PrettyTable(["Result", "Target", "Toolchain", "Test ID", "Test Description", + "Elapsed Time (sec)", "Timeout (sec)"]) + pt.align["Result"] = "l" # Left align + pt.align["Target"] = "l" # Left align + pt.align["Toolchain"] = "l" # Left align + pt.align["Test ID"] = "l" # Left align + pt.align["Test Description"] = "l" # Left align + pt.padding_width = 1 # One space between column edges and contents (default) + + for test in test_summary: + if test[0] in result_dict: + result_dict[test[0]] += 1 + pt.add_row(test) + print pt + + # Print result count + print "Result: " + ' / '.join(['%s %s' % (value, key) for (key, value) in {k: v for k, v in result_dict.items() if v != 0}.iteritems()]) + #print result_dict + print "Completed in %d sec" % (time() - start) diff --git a/workspace_tools/targets.py b/workspace_tools/targets.py index 6342e67a7b..922377a79c 100644 --- a/workspace_tools/targets.py +++ b/workspace_tools/targets.py @@ -101,6 +101,8 @@ class LPC11U24_301(Target): class KL05Z(Target): + ONLINE_TOOLCHAIN = "uARM" + def __init__(self): Target.__init__(self) @@ -282,7 +284,7 @@ class NUCLEO_F103RB(Target): self.extra_labels = ['STM', 'STM32F1', 'STM32F103RB'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] + self.supported_toolchains = ["ARM", "uARM"] class NUCLEO_L152RE(Target): @@ -296,7 +298,7 @@ class NUCLEO_L152RE(Target): self.extra_labels = ['STM', 'STM32L1', 'STM32L152RE'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] + self.supported_toolchains = ["ARM", "uARM"] class NUCLEO_F401RE(Target): @@ -310,7 +312,7 @@ class NUCLEO_F401RE(Target): self.extra_labels = ['STM', 'STM32F4', 'STM32F401RE'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] + self.supported_toolchains = ["ARM", "uARM"] class NUCLEO_F030R8(Target): @@ -324,7 +326,7 @@ class NUCLEO_F030R8(Target): self.extra_labels = ['STM', 'STM32F0', 'STM32F030R8'] - self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] + self.supported_toolchains = ["ARM", "uARM"] class LPC1347(Target): @@ -375,6 +377,19 @@ class LPC11U35_401(Target): self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"] +class LPC11U35_501(Target): + ONLINE_TOOLCHAIN = "uARM" + + def __init__(self): + Target.__init__(self) + + self.core = "Cortex-M0" + + self.extra_labels = ['NXP', 'LPC11UXX'] + + self.supported_toolchains = ["ARM", "uARM"] + + class UBLOX_C027(Target): def __init__(self): Target.__init__(self) @@ -418,9 +433,7 @@ class NRF51822(Target): t_self.debug("Hex file not found. Aborting.") return - # Generate hex file - # NOTE: this is temporary, it will be removed later and only the - # combined binary file (below) will be used + # Merge user code with softdevice from intelhex import IntelHex binh = IntelHex() binh.loadbin(binf, offset = NRF51822.APPCODE_OFFSET) @@ -433,8 +446,13 @@ class NRF51822(Target): with open(binf, "wb") as f: sdh.tofile(f, format = 'bin') + + #with open(binf.replace(".bin", ".hex"), "w") as f: + # sdh.tofile(f, format = 'hex') class LPC1549(Target): + ONLINE_TOOLCHAIN = "uARM" + def __init__(self): Target.__init__(self) @@ -467,6 +485,7 @@ TARGETS = [ LPC1114(), LPC11C24(), LPC11U35_401(), + LPC11U35_501(), NRF51822(), UBLOX_C027(), LPC1549() diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index ce11499964..a3bc041c7a 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -700,6 +700,11 @@ TESTS = [ "source_dir": join(TEST_DIR, "mbed", "fs"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB, SD_FS, FAT_FS], }, + { + "id": "NORDIC_1", "description": "BLE Health Thermometer full", + "source_dir": join(TEST_DIR, "nordic", "BLE_Health_Thermometer_full"), + "dependencies": [MBED_LIBRARIES, join(PERIPHERALS, 'TMP102')], + }, ] # Group tests with the same goals into categories From 1f962a16a43987728b0337542941c9d88cc0903f Mon Sep 17 00:00:00 2001 From: tkuyucu Date: Thu, 13 Mar 2014 12:37:09 +0100 Subject: [PATCH 4/5] Fixed syntactic bug in board.c --- libraries/mbed/common/board.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/mbed/common/board.c b/libraries/mbed/common/board.c index 3f6ca4aef6..ab24b09ec0 100644 --- a/libraries/mbed/common/board.c +++ b/libraries/mbed/common/board.c @@ -24,8 +24,6 @@ WEAK void mbed_die(void) { #endif #if (DEVICE_ERROR_RED == 1) gpio_t led_red; gpio_init_out(&led_red, LED_RED); -#endif - #elif (DEVICE_ERROR_PATTERN == 1) gpio_t led_1; gpio_init_out(&led_1, LED1); gpio_t led_2; gpio_init_out(&led_2, LED2); From ed8481eb97012564d6d2abc72ca645f7daccd09a Mon Sep 17 00:00:00 2001 From: Bogdan Marinescu Date: Wed, 19 Mar 2014 18:08:21 +0000 Subject: [PATCH 5/5] Updated library version --- libraries/mbed/api/mbed.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/mbed/api/mbed.h b/libraries/mbed/api/mbed.h index b95b01a9bc..ccfb982183 100644 --- a/libraries/mbed/api/mbed.h +++ b/libraries/mbed/api/mbed.h @@ -16,7 +16,7 @@ #ifndef MBED_H #define MBED_H -#define MBED_LIBRARY_VERSION 80 +#define MBED_LIBRARY_VERSION 81 #include "platform.h"