瀏覽代碼

Merge branch 'master' into step4

thread-liu 4 年之前
父節點
當前提交
d97530e0ff
共有 100 個文件被更改,包括 49 次插入16099 次删除
  1. 0 6
      bsp/CME_M7/applications/startup.c
  2. 2 2
      bsp/allwinner_tina/drivers/drv_uart.c
  3. 1 1
      bsp/allwinner_tina/drivers/spi/drv_spi.c
  4. 0 2
      bsp/avr32uc3b0/startup.c
  5. 0 6
      bsp/bf533/startup.c
  6. 0 6
      bsp/efm32/startup.c
  7. 0 6
      bsp/fh8620/platform/fh8620/iot_cam/startup.c
  8. 0 6
      bsp/frdm-k64f/applications/startup.c
  9. 0 5
      bsp/gkipc/armv6/rtos_lib.c
  10. 3 3
      bsp/imxrt/libraries/drivers/drv_can.h
  11. 28 1
      bsp/k210/.config
  12. 1 0
      bsp/k210/Kconfig
  13. 2 0
      bsp/k210/rtconfig.h
  14. 1 1
      bsp/k210/rtconfig.py
  15. 0 6
      bsp/lm3s8962/applications/startup.c
  16. 0 6
      bsp/lm3s9b9x/applications/startup.c
  17. 0 6
      bsp/lm4f232/applications/startup.c
  18. 0 6
      bsp/lpc2148/applications/startup.c
  19. 0 6
      bsp/lpc2478/applications/startup.c
  20. 5 0
      bsp/lpc43xx/M0/applications/vbus_hw.h
  21. 5 0
      bsp/lpc43xx/M4/applications/vbus_hw.h
  22. 0 6
      bsp/lpc5410x/applications/startup.c
  23. 0 6
      bsp/lpc824/applications/startup.c
  24. 1 7
      bsp/m16c62p/applications/startup.c
  25. 0 6
      bsp/mb9bf500r/startup.c
  26. 0 6
      bsp/microblaze/startup.c
  27. 0 6
      bsp/mini4020/applications/startup.c
  28. 0 6
      bsp/nios_ii/startup.c
  29. 0 6
      bsp/nrf51822/applications/startup.c
  30. 0 351
      bsp/nrf52832/.config
  31. 0 26
      bsp/nrf52832/Kconfig
  32. 0 16
      bsp/nrf52832/SConscript
  33. 0 35
      bsp/nrf52832/SConstruct
  34. 0 11
      bsp/nrf52832/applications/SConscript
  35. 0 48
      bsp/nrf52832/applications/application.c
  36. 0 670
      bsp/nrf52832/applications/ble_nus_app.c
  37. 0 3991
      bsp/nrf52832/applications/sdk_config.h
  38. 0 98
      bsp/nrf52832/applications/startup.c
  39. 0 14
      bsp/nrf52832/board/Sconscript
  40. 0 268
      bsp/nrf52832/board/board.c
  41. 0 13
      bsp/nrf52832/board/board.h
  42. 0 289
      bsp/nrf52832/board/uart.c
  43. 0 19
      bsp/nrf52832/board/uart.h
  44. 0 34
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/Sconscript
  45. 0 52
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/SConscript
  46. 0 86
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_channel_config/ant_channel_config.c
  47. 0 98
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_channel_config/ant_channel_config.h
  48. 0 239
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_encryption/ant_encrypt_config.c
  49. 0 255
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_encryption/ant_encrypt_config.h
  50. 0 189
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_encryption/ant_encrypt_negotiation_slave.c
  51. 0 140
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_encryption/ant_encrypt_negotiation_slave.h
  52. 0 2379
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/antfs.c
  53. 0 396
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/antfs.h
  54. 0 98
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/crc.c
  55. 0 94
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/crc.h
  56. 0 109
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/defines.h
  57. 0 67
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_key_manager/ant_key_manager.c
  58. 0 104
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_key_manager/ant_key_manager.h
  59. 0 69
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_key_manager/config/ant_key_manager_config.h
  60. 0 491
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/ant_bpwr.c
  61. 0 374
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/ant_bpwr.h
  62. 0 89
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/ant_bpwr_local.h
  63. 0 98
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_common_data.c
  64. 0 99
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_common_data.h
  65. 0 285
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_1.c
  66. 0 136
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_1.h
  67. 0 116
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_16.c
  68. 0 111
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_16.h
  69. 0 76
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_17.c
  70. 0 89
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_17.h
  71. 0 76
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_18.c
  72. 0 89
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_18.h
  73. 0 112
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_torque.c
  74. 0 106
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_torque.h
  75. 0 69
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_pages.h
  76. 0 201
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/simulator/ant_bpwr_simulator.c
  77. 0 123
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/simulator/ant_bpwr_simulator.h
  78. 0 74
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/simulator/ant_bpwr_simulator_local.h
  79. 0 86
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/utils/ant_bpwr_utils.h
  80. 0 420
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/ant_bsc.c
  81. 0 361
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/ant_bsc.h
  82. 0 83
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/ant_bsc_local.h
  83. 0 128
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_combined_page_0.c
  84. 0 99
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_combined_page_0.h
  85. 0 110
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_0.c
  86. 0 95
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_0.h
  87. 0 93
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_1.c
  88. 0 93
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_1.h
  89. 0 95
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_2.c
  90. 0 95
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_2.h
  91. 0 93
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_3.c
  92. 0 97
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_3.h
  93. 0 103
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_4.c
  94. 0 113
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_4.h
  95. 0 96
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_5.c
  96. 0 95
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_5.h
  97. 0 69
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_pages.h
  98. 0 280
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/simulator/ant_bsc_simulator.c
  99. 0 120
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/simulator/ant_bsc_simulator.h
  100. 0 79
      bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/simulator/ant_bsc_simulator_local.h

+ 0 - 6
bsp/CME_M7/applications/startup.c

@@ -47,12 +47,6 @@ void rtthread_startup(void)
     /* show version */
     rt_show_version();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     /* init timer system */
     rt_system_timer_init();
 

+ 2 - 2
bsp/allwinner_tina/drivers/drv_uart.c

@@ -120,8 +120,8 @@ int rt_hw_uart_init(void)
         uart->irqno        = UART1_INTERRUPT; // IRQ_UART1;
         uart->gpio_rx_port = GPIO_PORT_A;
         uart->gpio_tx_port = GPIO_PORT_A;
-        uart->gpio_rx_pin  = GPIO_PIN_3;
-        uart->gpio_tx_pin  = GPIO_PIN_2;
+        uart->gpio_rx_pin  = GPIO_PIN_2;
+        uart->gpio_tx_pin  = GPIO_PIN_3;
         uart->gpio_rx_fun  = IO_FUN_4;
         uart->gpio_tx_fun  = IO_FUN_4;
 

+ 1 - 1
bsp/allwinner_tina/drivers/spi/drv_spi.c

@@ -483,7 +483,7 @@ static rt_err_t configure(struct rt_spi_device *device,
         SPI_SetFirstTransmitBit(spi, SPI_TCTRL_FBS_LSB);
     }
 
-    switch (configuration->mode)
+    switch (configuration->mode & RT_SPI_MODE_3)
     {
     case RT_SPI_MODE_0:
         SPI_SetSclkMode(spi, SPI_SCLK_Mode0);

+ 0 - 2
bsp/avr32uc3b0/startup.c

@@ -30,8 +30,6 @@ int main(void)
 #endif
 
 	rt_hw_board_init();
-	rt_system_tick_init();
-	rt_system_object_init();
 	rt_system_timer_init();
 
 #ifdef RT_USING_HEAP

+ 0 - 6
bsp/bf533/startup.c

@@ -35,12 +35,6 @@ void rtthread_startup(void)
     /* show version */
     rt_show_version();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     /* init timer system */
     rt_system_timer_init();
 

+ 0 - 6
bsp/efm32/startup.c

@@ -102,12 +102,6 @@ void rtthread_startup(void)
     /* show version */
     rt_show_version();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     /* init timer system */
     rt_system_timer_init();
 

+ 0 - 6
bsp/fh8620/platform/fh8620/iot_cam/startup.c

@@ -93,12 +93,6 @@ void rtthread_startup(void)
 	/* show version */
 	rt_show_version();
 
-	/* initialize tick */
-	rt_system_tick_init();
-
-	/* initialize kernel object */
-	rt_system_object_init();
-
 	/* initialize timer system */
 	rt_system_timer_init();
 

+ 0 - 6
bsp/frdm-k64f/applications/startup.c

@@ -65,12 +65,6 @@ void rtthread_startup(void)
     /* show version */
     rt_show_version();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     /* init timer system */
     rt_system_timer_init();
 

+ 0 - 5
bsp/gkipc/armv6/rtos_lib.c

@@ -1095,14 +1095,9 @@ U32 RTOS_InitKernel(U32 Heap_size)
     /* show version */
     //rt_show_version();
 
-    /* initialize tick */
-    //rt_system_tick_init();
     RTOS_HwTickInit();
     //rt_kprintf("set tick\n");
 
-    /* initialize kernel object */
-    rt_system_object_init();
-
     /* initialize timer system */
     rt_system_timer_init();
 

+ 3 - 3
bsp/imxrt/libraries/drivers/drv_can.h

@@ -8,9 +8,9 @@
  * 2019-06-28     misonyo     the first version.
  */
  
-#ifndef DRV_SPI_H__
-#define DRV_SPI_H__
+#ifndef DRV_CAN_H__
+#define DRV_CAN_H__
 
 int rt_hw_can_init(void);
 
-#endif /* DRV_SPI_H__ */
+#endif /* DRV_CAN_H__ */

+ 28 - 1
bsp/k210/.config

@@ -70,6 +70,8 @@ CONFIG_RT_VER_NUM=0x40003
 CONFIG_ARCH_CPU_64BIT=y
 # CONFIG_RT_USING_CPU_FFS is not set
 CONFIG_ARCH_RISCV=y
+CONFIG_ARCH_RISCV_FPU=y
+CONFIG_ARCH_RISCV_FPU_S=y
 CONFIG_ARCH_RISCV64=y
 # CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
 
@@ -150,8 +152,10 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
 # CONFIG_RT_USING_HWTIMER is not set
 # CONFIG_RT_USING_CPUTIME is not set
 # CONFIG_RT_USING_I2C is not set
+# CONFIG_RT_USING_PHY is not set
 CONFIG_RT_USING_PIN=y
 # CONFIG_RT_USING_ADC is not set
+# CONFIG_RT_USING_DAC is not set
 # CONFIG_RT_USING_PWM is not set
 # CONFIG_RT_USING_MTD_NOR is not set
 # CONFIG_RT_USING_MTD_NAND is not set
@@ -192,6 +196,7 @@ CONFIG_RT_USING_LIBC=y
 CONFIG_RT_USING_POSIX=y
 # CONFIG_RT_USING_POSIX_MMAP is not set
 # CONFIG_RT_USING_POSIX_TERMIOS is not set
+# CONFIG_RT_USING_POSIX_GETLINE is not set
 # CONFIG_RT_USING_POSIX_AIO is not set
 # CONFIG_RT_USING_MODULE is not set
 
@@ -262,7 +267,9 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
 #
 # IoT - internet of things
 #
+# CONFIG_PKG_USING_LORAWAN_DRIVER is not set
 # CONFIG_PKG_USING_PAHOMQTT is not set
+# CONFIG_PKG_USING_UMQTT is not set
 # CONFIG_PKG_USING_WEBCLIENT is not set
 # CONFIG_PKG_USING_WEBNET is not set
 # CONFIG_PKG_USING_MONGOOSE is not set
@@ -308,7 +315,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
 # CONFIG_PKG_USING_GAGENT_CLOUD is not set
 # CONFIG_PKG_USING_ALI_IOTKIT is not set
 # CONFIG_PKG_USING_AZURE is not set
-# CONFIG_PKG_USING_TENCENT_IOTHUB is not set
+# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set
 # CONFIG_PKG_USING_JIOT-C-SDK is not set
 # CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
 # CONFIG_PKG_USING_JOYLINK is not set
@@ -330,6 +337,9 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
 # CONFIG_PKG_USING_CAPNP is not set
 # CONFIG_PKG_USING_RT_CJSON_TOOLS is not set
 # CONFIG_PKG_USING_AGILE_TELNET is not set
+# CONFIG_PKG_USING_NMEALIB is not set
+# CONFIG_PKG_USING_AGILE_JSMN is not set
+# CONFIG_PKG_USING_PDULIB is not set
 
 #
 # security packages
@@ -338,6 +348,7 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
 # CONFIG_PKG_USING_libsodium is not set
 # CONFIG_PKG_USING_TINYCRYPT is not set
 # CONFIG_PKG_USING_TFM is not set
+# CONFIG_PKG_USING_YD_CRYPTO is not set
 
 #
 # language packages
@@ -372,7 +383,9 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
 # CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set
 # CONFIG_PKG_USING_LUNAR_CALENDAR is not set
 # CONFIG_PKG_USING_BS8116A is not set
+# CONFIG_PKG_USING_GPS_RMC is not set
 # CONFIG_PKG_USING_URLENCODE is not set
+# CONFIG_PKG_USING_UMCN is not set
 
 #
 # system packages
@@ -396,6 +409,10 @@ CONFIG_ULOG_BACKEND_USING_CONSOLE=y
 # CONFIG_PKG_USING_SYSWATCH is not set
 # CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set
 # CONFIG_PKG_USING_PLCCORE is not set
+# CONFIG_PKG_USING_RAMDISK is not set
+# CONFIG_PKG_USING_MININI is not set
+# CONFIG_PKG_USING_QBOOT is not set
+# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
 
 #
 # peripheral libraries and drivers
@@ -441,6 +458,7 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055
 # CONFIG_PKG_USING_RPLIDAR is not set
 # CONFIG_PKG_USING_AS608 is not set
 # CONFIG_PKG_USING_RC522 is not set
+# CONFIG_PKG_USING_WS2812B is not set
 # CONFIG_PKG_USING_EMBARC_BSP is not set
 # CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set
 # CONFIG_PKG_USING_MULTI_RTIMER is not set
@@ -450,6 +468,12 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055
 # CONFIG_PKG_USING_PMS_SERIES is not set
 # CONFIG_PKG_USING_NUCLEI_SDK is not set
 # CONFIG_PKG_USING_CAN_YMODEM is not set
+# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set
+# CONFIG_PKG_USING_QLED is not set
+# CONFIG_PKG_USING_PAJ7620 is not set
+# CONFIG_PKG_USING_AGILE_CONSOLE is not set
+# CONFIG_PKG_USING_LD3320 is not set
+# CONFIG_PKG_USING_WK2124 is not set
 
 #
 # miscellaneous packages
@@ -486,6 +510,9 @@ CONFIG_PKG_KENDRYTE_SDK_VERNUM=0x0055
 # CONFIG_PKG_USING_VT100 is not set
 # CONFIG_PKG_USING_ULAPACK is not set
 # CONFIG_PKG_USING_UKAL is not set
+# CONFIG_PKG_USING_CRCLIB is not set
+# CONFIG_PKG_USING_THREES is not set
+# CONFIG_PKG_USING_2048 is not set
 CONFIG_BOARD_K210_EVB=y
 CONFIG_BSP_USING_UART_HS=y
 

+ 1 - 0
bsp/k210/Kconfig

@@ -21,6 +21,7 @@ source "$PKGS_DIR/Kconfig"
 config BOARD_K210_EVB
     bool
     select ARCH_RISCV64
+    select ARCH_RISCV_FPU_S
     select PKG_USING_KENDRYTE_SDK
     select RT_USING_COMPONENTS_INIT
     select RT_USING_USER_MAIN

+ 2 - 0
bsp/k210/rtconfig.h

@@ -48,6 +48,8 @@
 #define RT_VER_NUM 0x40003
 #define ARCH_CPU_64BIT
 #define ARCH_RISCV
+#define ARCH_RISCV_FPU
+#define ARCH_RISCV_FPU_S
 #define ARCH_RISCV64
 
 /* RT-Thread Components */

+ 1 - 1
bsp/k210/rtconfig.py

@@ -38,7 +38,7 @@ if PLATFORM == 'gcc':
     OBJDUMP = PREFIX + 'objdump'
     OBJCPY  = PREFIX + 'objcopy'
 
-    DEVICE  = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64d'
+    DEVICE  = ' -mcmodel=medany -march=rv64imafc -mabi=lp64f -fsingle-precision-constant'
     CFLAGS  = DEVICE + ' -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields'
     AFLAGS  = ' -c' + DEVICE + ' -x assembler-with-cpp'
     LFLAGS  = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds'

+ 0 - 6
bsp/lm3s8962/applications/startup.c

@@ -77,12 +77,6 @@ void rtthread_startup(void)
 	/* show version */
 	rt_show_version();
 
-	/* init tick */
-	rt_system_tick_init();
-
-	/* init kernel object */
-	rt_system_object_init();
-
 	/* init timer system */
 	rt_system_timer_init();
 

+ 0 - 6
bsp/lm3s9b9x/applications/startup.c

@@ -77,12 +77,6 @@ void rtthread_startup(void)
 	/* show version */
 	rt_show_version();
 
-	/* init tick */
-	rt_system_tick_init();
-
-	/* init kernel object */
-	rt_system_object_init();
-
 	/* init timer system */
 	rt_system_timer_init();
 

+ 0 - 6
bsp/lm4f232/applications/startup.c

@@ -77,12 +77,6 @@ void rtthread_startup(void)
 	/* show version */
 	rt_show_version();
 
-	/* init tick */
-	rt_system_tick_init();
-
-	/* init kernel object */
-	rt_system_object_init();
-
 	/* init timer system */
 	rt_system_timer_init();
 

+ 0 - 6
bsp/lpc2148/applications/startup.c

@@ -52,12 +52,6 @@ void rtthread_startup(void)
     /* init board */
     rt_hw_board_init();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     rt_show_version();
 
     /* init timer system */

+ 0 - 6
bsp/lpc2478/applications/startup.c

@@ -38,12 +38,6 @@ void rtthread_startup(void)
     /* init board */
     rt_hw_board_init();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     rt_show_version();
 
     /* init timer system */

+ 5 - 0
bsp/lpc43xx/M0/applications/vbus_hw.h

@@ -7,6 +7,9 @@
  * 2015-01-07     Grissiom     init commit
  */
 
+#ifndef __VBUS_HW_H__
+#define __VBUS_HW_H__
+
 #include <rtthread.h>
 #include <board.h>
 
@@ -32,3 +35,5 @@ rt_inline void rt_vbus_smp_mb(void)
 {
     __DSB();
 }
+
+#endif /* __VBUS_HW_H__ */

+ 5 - 0
bsp/lpc43xx/M4/applications/vbus_hw.h

@@ -7,6 +7,9 @@
  * 2015-01-07     Grissiom     init commit
  */
 
+#ifndef __VBUS_HW_H__
+#define __VBUS_HW_H__
+
 #include <rtthread.h>
 #include <board.h>
 
@@ -32,3 +35,5 @@ rt_inline void rt_vbus_smp_mb(void)
 {
     __DSB();
 }
+
+#endif /* __VBUS_HW_H__ */

+ 0 - 6
bsp/lpc5410x/applications/startup.c

@@ -27,12 +27,6 @@ void rtthread_startup(void)
     /* show version */
     rt_show_version();
 
-    /* initialize tick */
-    rt_system_tick_init();
-
-    /* initialize kernel object */
-    rt_system_object_init();
-
     /* initialize timer system */
     rt_system_timer_init();
 

+ 0 - 6
bsp/lpc824/applications/startup.c

@@ -52,12 +52,6 @@ void rtthread_startup(void)
     /* show version */
     rt_show_version();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     /* init timer system */
     rt_system_timer_init();
 

+ 1 - 7
bsp/m16c62p/applications/startup.c

@@ -48,13 +48,7 @@ void rtthread_startup(void)
 
 	/* show version */
 	rt_show_version();
-
-	/* init tick */
-	rt_system_tick_init();
-    
-	/* init kernel object */
-	rt_system_object_init();
-    
+        
 	/* init timer system */
 	rt_system_timer_init();
     

+ 0 - 6
bsp/mb9bf500r/startup.c

@@ -44,12 +44,6 @@ void rtthread_startup(void)
 	/* show version */
 	rt_show_version();
 
-	/* init tick */
-	rt_system_tick_init();
-
-	/* init kernel object */
-	rt_system_object_init();
-
 	/* init timer system */
 	rt_system_timer_init();
 

+ 0 - 6
bsp/microblaze/startup.c

@@ -55,12 +55,6 @@ void rtthread_startup(void)
 	
 	rt_show_version();
 
-	/* init tick */
-	rt_system_tick_init();
-
-	/* init kernel object */
-	rt_system_object_init();
-
 	/* init timer system */
 	rt_system_timer_init();
 

+ 0 - 6
bsp/mini4020/applications/startup.c

@@ -49,12 +49,6 @@ void rtthread_startup()
 	/* show version */
 	rt_show_version();
 		
-	/* init tick */
-	rt_system_tick_init();
-
-	/* init kernel object */
-	rt_system_object_init();
-
 	/* init timer system */
 	rt_system_timer_init();
 

+ 0 - 6
bsp/nios_ii/startup.c

@@ -45,12 +45,6 @@ void rtthread_startup(void)
     /* show version */
     rt_show_version();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     /* init timer system */
     rt_system_timer_init();
 

+ 0 - 6
bsp/nrf51822/applications/startup.c

@@ -48,12 +48,6 @@ void rtthread_startup(void)
     /* show version */
     rt_show_version();
 
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
     /* init timer system */
     rt_system_timer_init();
 

+ 0 - 351
bsp/nrf52832/.config

@@ -1,351 +0,0 @@
-#
-# Automatically generated file; DO NOT EDIT.
-# RT-Thread Project Configuration
-#
-
-#
-# RT-Thread Kernel
-#
-CONFIG_RT_NAME_MAX=8
-# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
-# CONFIG_RT_USING_SMP is not set
-CONFIG_RT_ALIGN_SIZE=4
-# CONFIG_RT_THREAD_PRIORITY_8 is not set
-CONFIG_RT_THREAD_PRIORITY_32=y
-# CONFIG_RT_THREAD_PRIORITY_256 is not set
-CONFIG_RT_THREAD_PRIORITY_MAX=32
-CONFIG_RT_TICK_PER_SECOND=100
-CONFIG_RT_USING_OVERFLOW_CHECK=y
-CONFIG_RT_USING_HOOK=y
-CONFIG_RT_USING_IDLE_HOOK=y
-CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
-CONFIG_IDLE_THREAD_STACK_SIZE=256
-CONFIG_RT_USING_TIMER_SOFT=y
-CONFIG_RT_TIMER_THREAD_PRIO=4
-CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
-CONFIG_RT_DEBUG=y
-# CONFIG_RT_DEBUG_COLOR is not set
-# CONFIG_RT_DEBUG_INIT_CONFIG is not set
-# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
-# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
-# CONFIG_RT_DEBUG_IPC_CONFIG is not set
-# CONFIG_RT_DEBUG_TIMER_CONFIG is not set
-# CONFIG_RT_DEBUG_IRQ_CONFIG is not set
-# CONFIG_RT_DEBUG_MEM_CONFIG is not set
-# CONFIG_RT_DEBUG_SLAB_CONFIG is not set
-# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set
-# CONFIG_RT_DEBUG_MODULE_CONFIG is not set
-
-#
-# Inter-Thread communication
-#
-CONFIG_RT_USING_SEMAPHORE=y
-CONFIG_RT_USING_MUTEX=y
-CONFIG_RT_USING_EVENT=y
-CONFIG_RT_USING_MAILBOX=y
-CONFIG_RT_USING_MESSAGEQUEUE=y
-# CONFIG_RT_USING_SIGNALS is not set
-
-#
-# Memory Management
-#
-CONFIG_RT_USING_MEMPOOL=y
-# CONFIG_RT_USING_MEMHEAP is not set
-# CONFIG_RT_USING_NOHEAP is not set
-CONFIG_RT_USING_SMALL_MEM=y
-# CONFIG_RT_USING_SLAB is not set
-# CONFIG_RT_USING_MEMTRACE is not set
-CONFIG_RT_USING_HEAP=y
-
-#
-# Kernel Device Object
-#
-CONFIG_RT_USING_DEVICE=y
-# CONFIG_RT_USING_DEVICE_OPS is not set
-# CONFIG_RT_USING_INTERRUPT_INFO is not set
-CONFIG_RT_USING_CONSOLE=y
-CONFIG_RT_CONSOLEBUF_SIZE=128
-CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
-CONFIG_RT_VER_NUM=0x40002
-# CONFIG_RT_USING_CPU_FFS is not set
-# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
-
-#
-# RT-Thread Components
-#
-CONFIG_RT_USING_COMPONENTS_INIT=y
-# CONFIG_RT_USING_USER_MAIN is not set
-
-#
-# C++ features
-#
-# CONFIG_RT_USING_CPLUSPLUS is not set
-
-#
-# Command shell
-#
-CONFIG_RT_USING_FINSH=y
-CONFIG_FINSH_THREAD_NAME="tshell"
-CONFIG_FINSH_USING_HISTORY=y
-CONFIG_FINSH_HISTORY_LINES=5
-CONFIG_FINSH_USING_SYMTAB=y
-CONFIG_FINSH_USING_DESCRIPTION=y
-# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
-CONFIG_FINSH_THREAD_PRIORITY=20
-CONFIG_FINSH_THREAD_STACK_SIZE=4096
-CONFIG_FINSH_CMD_SIZE=80
-# CONFIG_FINSH_USING_AUTH is not set
-CONFIG_FINSH_USING_MSH=y
-CONFIG_FINSH_USING_MSH_DEFAULT=y
-CONFIG_FINSH_USING_MSH_ONLY=y
-CONFIG_FINSH_ARG_MAX=10
-
-#
-# Device virtual file system
-#
-# CONFIG_RT_USING_DFS is not set
-
-#
-# Device Drivers
-#
-CONFIG_RT_USING_DEVICE_IPC=y
-CONFIG_RT_PIPE_BUFSZ=512
-# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set
-CONFIG_RT_USING_SERIAL=y
-CONFIG_RT_SERIAL_USING_DMA=y
-CONFIG_RT_SERIAL_RB_BUFSZ=64
-# CONFIG_RT_USING_CAN is not set
-# CONFIG_RT_USING_HWTIMER is not set
-# CONFIG_RT_USING_CPUTIME is not set
-# CONFIG_RT_USING_I2C is not set
-CONFIG_RT_USING_PIN=y
-# CONFIG_RT_USING_ADC is not set
-# CONFIG_RT_USING_PWM is not set
-# CONFIG_RT_USING_MTD_NOR is not set
-# CONFIG_RT_USING_MTD_NAND is not set
-# CONFIG_RT_USING_PM is not set
-# CONFIG_RT_USING_RTC is not set
-# CONFIG_RT_USING_SDIO is not set
-# CONFIG_RT_USING_SPI is not set
-# CONFIG_RT_USING_WDT is not set
-# CONFIG_RT_USING_AUDIO is not set
-# CONFIG_RT_USING_SENSOR is not set
-# CONFIG_RT_USING_TOUCH is not set
-
-#
-# Using Hardware Crypto drivers
-#
-# CONFIG_RT_USING_HWCRYPTO is not set
-
-#
-# Using WiFi
-#
-# CONFIG_RT_USING_WIFI is not set
-
-#
-# Using USB
-#
-# CONFIG_RT_USING_USB_HOST is not set
-# CONFIG_RT_USING_USB_DEVICE is not set
-
-#
-# POSIX layer and C standard library
-#
-CONFIG_RT_USING_LIBC=y
-# CONFIG_RT_USING_PTHREADS is not set
-
-#
-# Network
-#
-
-#
-# Socket abstraction layer
-#
-# CONFIG_RT_USING_SAL is not set
-
-#
-# Network interface device
-#
-# CONFIG_RT_USING_NETDEV is not set
-
-#
-# light weight TCP/IP stack
-#
-# CONFIG_RT_USING_LWIP is not set
-
-#
-# AT commands
-#
-# CONFIG_RT_USING_AT is not set
-
-#
-# VBUS(Virtual Software BUS)
-#
-# CONFIG_RT_USING_VBUS is not set
-
-#
-# Utilities
-#
-# CONFIG_RT_USING_RYM is not set
-# CONFIG_RT_USING_ULOG is not set
-# CONFIG_RT_USING_UTEST is not set
-
-#
-# RT-Thread online packages
-#
-
-#
-# IoT - internet of things
-#
-# CONFIG_PKG_USING_PAHOMQTT is not set
-# CONFIG_PKG_USING_WEBCLIENT is not set
-# CONFIG_PKG_USING_WEBNET is not set
-# CONFIG_PKG_USING_MONGOOSE is not set
-# CONFIG_PKG_USING_WEBTERMINAL is not set
-# CONFIG_PKG_USING_CJSON is not set
-# CONFIG_PKG_USING_JSMN is not set
-# CONFIG_PKG_USING_LIBMODBUS is not set
-# CONFIG_PKG_USING_FREEMODBUS is not set
-# CONFIG_PKG_USING_LJSON is not set
-# CONFIG_PKG_USING_EZXML is not set
-# CONFIG_PKG_USING_NANOPB is not set
-
-#
-# Wi-Fi
-#
-
-#
-# Marvell WiFi
-#
-# CONFIG_PKG_USING_WLANMARVELL is not set
-
-#
-# Wiced WiFi
-#
-# CONFIG_PKG_USING_WLAN_WICED is not set
-# CONFIG_PKG_USING_RW007 is not set
-# CONFIG_PKG_USING_COAP is not set
-# CONFIG_PKG_USING_NOPOLL is not set
-# CONFIG_PKG_USING_NETUTILS is not set
-# CONFIG_PKG_USING_AT_DEVICE is not set
-# CONFIG_PKG_USING_ATSRV_SOCKET is not set
-# CONFIG_PKG_USING_WIZNET is not set
-
-#
-# IoT Cloud
-#
-# CONFIG_PKG_USING_ONENET is not set
-# CONFIG_PKG_USING_GAGENT_CLOUD is not set
-# CONFIG_PKG_USING_ALI_IOTKIT is not set
-# CONFIG_PKG_USING_AZURE is not set
-# CONFIG_PKG_USING_TENCENT_IOTHUB is not set
-# CONFIG_PKG_USING_NIMBLE is not set
-# CONFIG_PKG_USING_OTA_DOWNLOADER is not set
-# CONFIG_PKG_USING_IPMSG is not set
-# CONFIG_PKG_USING_LSSDP is not set
-# CONFIG_PKG_USING_AIRKISS_OPEN is not set
-# CONFIG_PKG_USING_LIBRWS is not set
-
-#
-# security packages
-#
-# CONFIG_PKG_USING_MBEDTLS is not set
-# CONFIG_PKG_USING_libsodium is not set
-# CONFIG_PKG_USING_TINYCRYPT is not set
-
-#
-# language packages
-#
-# CONFIG_PKG_USING_LUA is not set
-# CONFIG_PKG_USING_JERRYSCRIPT is not set
-# CONFIG_PKG_USING_MICROPYTHON is not set
-
-#
-# multimedia packages
-#
-# CONFIG_PKG_USING_OPENMV is not set
-# CONFIG_PKG_USING_MUPDF is not set
-# CONFIG_PKG_USING_STEMWIN is not set
-
-#
-# tools packages
-#
-# CONFIG_PKG_USING_CMBACKTRACE is not set
-# CONFIG_PKG_USING_EASYFLASH is not set
-# CONFIG_PKG_USING_EASYLOGGER is not set
-# CONFIG_PKG_USING_SYSTEMVIEW is not set
-# CONFIG_PKG_USING_RDB is not set
-# CONFIG_PKG_USING_QRCODE is not set
-# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
-# CONFIG_PKG_USING_ADBD is not set
-
-#
-# system packages
-#
-# CONFIG_PKG_USING_GUIENGINE is not set
-# CONFIG_PKG_USING_CAIRO is not set
-# CONFIG_PKG_USING_PIXMAN is not set
-# CONFIG_PKG_USING_LWEXT4 is not set
-# CONFIG_PKG_USING_PARTITION is not set
-# CONFIG_PKG_USING_FAL is not set
-# CONFIG_PKG_USING_SQLITE is not set
-# CONFIG_PKG_USING_RTI is not set
-# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
-# CONFIG_PKG_USING_CMSIS is not set
-# CONFIG_PKG_USING_DFS_YAFFS is not set
-# CONFIG_PKG_USING_LITTLEFS is not set
-# CONFIG_PKG_USING_THREAD_POOL is not set
-
-#
-# peripheral libraries and drivers
-#
-# CONFIG_PKG_USING_SENSORS_DRIVERS is not set
-# CONFIG_PKG_USING_REALTEK_AMEBA is not set
-# CONFIG_PKG_USING_SHT2X is not set
-# CONFIG_PKG_USING_STM32_SDIO is not set
-# CONFIG_PKG_USING_ICM20608 is not set
-# CONFIG_PKG_USING_U8G2 is not set
-# CONFIG_PKG_USING_BUTTON is not set
-# CONFIG_PKG_USING_PCF8574 is not set
-# CONFIG_PKG_USING_SX12XX is not set
-# CONFIG_PKG_USING_SIGNAL_LED is not set
-# CONFIG_PKG_USING_LEDBLINK is not set
-# CONFIG_PKG_USING_WM_LIBRARIES is not set
-# CONFIG_PKG_USING_KENDRYTE_SDK is not set
-# CONFIG_PKG_USING_INFRARED is not set
-# CONFIG_PKG_USING_ROSSERIAL is not set
-# CONFIG_PKG_USING_AT24CXX is not set
-# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set
-# CONFIG_PKG_USING_AD7746 is not set
-# CONFIG_PKG_USING_PCA9685 is not set
-# CONFIG_PKG_USING_I2C_TOOLS is not set
-# CONFIG_PKG_USING_NRF24L01 is not set
-# CONFIG_PKG_USING_TOUCH_DRIVERS is not set
-
-#
-# miscellaneous packages
-#
-# CONFIG_PKG_USING_LIBCSV is not set
-# CONFIG_PKG_USING_OPTPARSE is not set
-# CONFIG_PKG_USING_FASTLZ is not set
-# CONFIG_PKG_USING_MINILZO is not set
-# CONFIG_PKG_USING_QUICKLZ is not set
-# CONFIG_PKG_USING_MULTIBUTTON is not set
-# CONFIG_PKG_USING_CANFESTIVAL is not set
-# CONFIG_PKG_USING_ZLIB is not set
-# CONFIG_PKG_USING_DSTR is not set
-# CONFIG_PKG_USING_TINYFRAME is not set
-# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
-# CONFIG_PKG_USING_DIGITALCTRL is not set
-
-#
-# samples: kernel and components samples
-#
-# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
-# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
-# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
-# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
-# CONFIG_PKG_USING_HELLO is not set
-# CONFIG_PKG_USING_VI is not set
-# CONFIG_PKG_USING_NNOM is not set
-# CONFIG_PKG_USING_LIBANN is not set

+ 0 - 26
bsp/nrf52832/Kconfig

@@ -1,26 +0,0 @@
-mainmenu "RT-Thread Project Configuration"
-
-config BSP_DIR
-    string
-    option env="BSP_ROOT"
-    default "."
-
-config RTT_DIR
-    string
-    option env="RTT_ROOT"
-    default "../.."
-
-config PKGS_DIR
-    string
-    option env="PKGS_ROOT"
-    default "packages"
-
-source "$RTT_DIR/Kconfig"
-source "$PKGS_DIR/Kconfig"
-
-config SOC_NRF52832
-    bool
-    select RT_USING_COMPONENTS_INIT
-    # select RT_USING_USER_MAIN
-    default y
-

+ 0 - 16
bsp/nrf52832/SConscript

@@ -1,16 +0,0 @@
-# for module compiling
-import os
-from building import *
-
-cwd  = GetCurrentDir()
-objs = []
-list = os.listdir(cwd)
-
-for d in list:
-    path = os.path.join(cwd, d)
-    if os.path.isfile(os.path.join(path, 'SConscript')):
-        objs = objs + SConscript(os.path.join(d, 'SConscript'))
-
-objs = objs + SConscript(os.path.join(cwd, 'nRF5_SDK_13.0.0_04a0bfd/components/SConscript'))
-
-Return('objs')

+ 0 - 35
bsp/nrf52832/SConstruct

@@ -1,35 +0,0 @@
-import os
-import sys
-import rtconfig
-
-if os.getenv('RTT_ROOT'):
-    RTT_ROOT = os.getenv('RTT_ROOT')
-else:
-    RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
-
-sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
-from building import *
-
-TARGET = 'rtthread_nrf52832.' + rtconfig.TARGET_EXT
-
-DefaultEnvironment(tools=[])
-env = Environment(tools = ['mingw'],
-	AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
-	CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
-	AR = rtconfig.AR, ARFLAGS = '-rc',
-	LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
-env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
-
-if rtconfig.PLATFORM == 'iar':
-	env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
-	env.Replace(ARFLAGS = [''])
-	env.Replace(LINKCOM = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map project.map'])
-
-Export('RTT_ROOT')
-Export('rtconfig')
-
-# prepare building environment
-objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
-
-# make a building
-DoBuilding(TARGET, objs)

+ 0 - 11
bsp/nrf52832/applications/SConscript

@@ -1,11 +0,0 @@
-Import('RTT_ROOT')
-Import('rtconfig')
-from building import *
-
-cwd     = os.path.join(str(Dir('#')), 'applications')
-src	= Glob('*.c')
-CPPPATH = [cwd, str(Dir('#'))]
-
-group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
-
-Return('group')

+ 0 - 48
bsp/nrf52832/applications/application.c

@@ -1,48 +0,0 @@
-/*
- * File      : application.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2015, RT-Thread Development Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date           Author       Notes
- * 2015-03-01     Yangfs       the first version
- * 2015-03-27     Bernard      code cleanup.
- */
-
-/**
- * @addtogroup NRF52832
- */
-/*@{*/
-
-#include <rtthread.h>
-
-#ifdef RT_USING_FINSH
-#include <finsh.h>
-#include <shell.h>
-#endif
-
-void rt_init_thread_entry(void* parameter)
-{
-    extern rt_err_t ble_init(void);
-
-    ble_init();
-}
-
-int rt_application_init(void)
-{
-    rt_thread_t tid;
-
-    tid = rt_thread_create("init", rt_init_thread_entry, RT_NULL, 1024,
-                            RT_THREAD_PRIORITY_MAX / 3, 20);
-    if (tid != RT_NULL)
-        rt_thread_startup(tid);
-
-    return 0;
-}
-
-
-/*@}*/

+ 0 - 670
bsp/nrf52832/applications/ble_nus_app.c

@@ -1,670 +0,0 @@
-#include "nordic_common.h"
-#include "nrf.h"
-#include "ble_hci.h"
-#include "ble_advdata.h"
-#include "ble_advertising.h"
-#include "ble_conn_params.h"
-#include "softdevice_handler.h"
-#include "nrf_ble_gatt.h"
-#include "app_timer.h"
-#include "ble_nus.h"
-#include "app_util_platform.h"
-
-#include <rtthread.h>
-
-typedef rt_size_t (*BLE_NOTIFY_T)(rt_uint8_t *buf, rt_uint16_t size);
-
-#define STACK_EVT_MQ_NUM        10
-
-#define FAST_ADV()          \
-    do {                    \
-        uint32_t err_code;  \
-        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);    \
-        APP_ERROR_CHECK(err_code);  \
-    } while(0)
-
-typedef enum
-{
-    STACK_EV_DISCON = 1,
-    STACK_EV_DISPATCH = 2,
-    STACK_EV_KEY = 4,
-} STACK_EV_E;
-
-typedef struct
-{
-    rt_list_t node;
-    void* evt;
-} evt_list_t;
-
-typedef enum
-{
-    STACK_STATE_IDLE = 0,
-    STACK_STATE_ADV = 1,
-    STACK_STATE_CON = 2,
-    STACK_STATE_DISC = 3
-} STACK_STATE_E;
-
-STACK_STATE_E stack_state = STACK_STATE_IDLE;
-
-rt_event_t stack_event;
-rt_sem_t sd_evt_sem;
-rt_mq_t stack_evt_mq;
-rt_uint8_t *evt_sample;
-
-BLE_NOTIFY_T rx_notify = RT_NULL;
-
-// Low frequency clock source to be used by the SoftDevice
-#define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_XTAL,            \
-                                 .rc_ctiv       = 0,                                \
-                                 .rc_temp_ctiv  = 0,                                \
-                                 .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
-
-
-#define CONN_CFG_TAG                    1                                           /**< A tag that refers to the BLE stack configuration we set with @ref sd_ble_cfg_set. Default tag is @ref BLE_CONN_CFG_TAG_DEFAULT. */
-
-#define APP_FEATURE_NOT_SUPPORTED       BLE_GATT_STATUS_ATTERR_APP_BEGIN + 2        /**< Reply when unsupported features are requested. */
-
-#define DEVICE_NAME                     "Nordic_UART"                               /**< Name of device. Will be included in the advertising data. */
-#define NUS_SERVICE_UUID_TYPE           BLE_UUID_TYPE_VENDOR_BEGIN                  /**< UUID type for the Nordic UART Service (vendor specific). */
-
-#define APP_ADV_INTERVAL                64                                          /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */
-#define APP_ADV_TIMEOUT_IN_SECONDS      30                                         /**< The advertising timeout (in units of seconds). */
-
-#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)             /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
-#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(75, UNIT_1_25_MS)             /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
-#define SLAVE_LATENCY                   0                                           /**< Slave latency. */
-#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
-#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                       /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
-#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                      /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
-#define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**< Number of attempts before giving up the connection parameter negotiation. */
-
-#define DEAD_BEEF                       0xDEADBEEF                                  /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */
-
-#define UART_TX_BUF_SIZE                256                                         /**< UART TX buffer size. */
-#define UART_RX_BUF_SIZE                256                                         /**< UART RX buffer size. */
-
-static ble_nus_t                        m_nus;                                      /**< Structure to identify the Nordic UART Service. */
-static uint16_t                         m_conn_handle = BLE_CONN_HANDLE_INVALID;    /**< Handle of the current connection. */
-
-static nrf_ble_gatt_t                   m_gatt;                                     /**< GATT module instance. */
-static ble_uuid_t                       m_adv_uuids[] = {{BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}};  /**< Universally unique service identifier. */
-static uint16_t                         m_ble_nus_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - 3;  /**< Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module. */
-
-/**@brief Function for assert macro callback.
- *
- * @details This function will be called in case of an assert in the SoftDevice.
- *
- * @warning This handler is an example only and does not fit a final product. You need to analyse
- *          how your product is supposed to react in case of Assert.
- * @warning On assert from the SoftDevice, the system can only recover on reset.
- *
- * @param[in] line_num    Line number of the failing ASSERT call.
- * @param[in] p_file_name File name of the failing ASSERT call.
- */
-void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
-{
-    app_error_handler(DEAD_BEEF, line_num, p_file_name);
-}
-
-
-/**@brief Function for the GAP initialization.
- *
- * @details This function will set up all the necessary GAP (Generic Access Profile) parameters of
- *          the device. It also sets the permissions and appearance.
- */
-static void gap_params_init(void)
-{
-    uint32_t                err_code;
-    ble_gap_conn_params_t   gap_conn_params;
-    ble_gap_conn_sec_mode_t sec_mode;
-
-    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
-
-    err_code = sd_ble_gap_device_name_set(&sec_mode,
-                                          (const uint8_t *) DEVICE_NAME,
-                                          strlen(DEVICE_NAME));
-    APP_ERROR_CHECK(err_code);
-
-    memset(&gap_conn_params, 0, sizeof(gap_conn_params));
-
-    gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
-    gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
-    gap_conn_params.slave_latency     = SLAVE_LATENCY;
-    gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;
-
-    err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
-    APP_ERROR_CHECK(err_code);
-}
-
-
-/**@brief Function for handling the data from the Nordic UART Service.
- *
- * @details This function will process the data received from the Nordic UART BLE Service and send
- *          it to the UART module.
- *
- * @param[in] p_nus    Nordic UART Service structure.
- * @param[in] p_data   Data to be send to UART module.
- * @param[in] length   Length of the data.
- */
-/**@snippet [Handling the data received over BLE] */
-static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
-{
-    rt_kprintf("Received data from BLE NUS. Writing data on UART.\r\n");
-
-    for (uint32_t i = 0; i < length; i++)
-    {
-        rt_kprintf("%02x ", p_data[i]);
-    }
-
-    // ble_send(p_data, length);
-
-    if (rx_notify != RT_NULL)
-    {
-        rx_notify(p_data, length);
-    }
-}
-/**@snippet [Handling the data received over BLE] */
-
-
-/**@brief Function for initializing services that will be used by the application.
- */
-static void services_init(void)
-{
-    uint32_t       err_code;
-    ble_nus_init_t nus_init;
-
-    memset(&nus_init, 0, sizeof(nus_init));
-
-    nus_init.data_handler = nus_data_handler;
-
-    err_code = ble_nus_init(&m_nus, &nus_init);
-    APP_ERROR_CHECK(err_code);
-}
-
-
-/**@brief Function for handling an event from the Connection Parameters Module.
- *
- * @details This function will be called for all events in the Connection Parameters Module
- *          which are passed to the application.
- *
- * @note All this function does is to disconnect. This could have been done by simply setting
- *       the disconnect_on_fail config parameter, but instead we use the event handler
- *       mechanism to demonstrate its use.
- *
- * @param[in] p_evt  Event received from the Connection Parameters Module.
- */
-static void on_conn_params_evt(ble_conn_params_evt_t * p_evt)
-{
-    uint32_t err_code;
-
-    if (p_evt->evt_type == BLE_CONN_PARAMS_EVT_FAILED)
-    {
-        err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
-        APP_ERROR_CHECK(err_code);
-    }
-}
-
-
-/**@brief Function for handling errors from the Connection Parameters module.
- *
- * @param[in] nrf_error  Error code containing information about what went wrong.
- */
-static void conn_params_error_handler(uint32_t nrf_error)
-{
-    APP_ERROR_HANDLER(nrf_error);
-}
-
-
-/**@brief Function for initializing the Connection Parameters module.
- */
-static void conn_params_init(void)
-{
-    uint32_t               err_code;
-    ble_conn_params_init_t cp_init;
-
-    memset(&cp_init, 0, sizeof(cp_init));
-
-    cp_init.p_conn_params                  = NULL;
-    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
-    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
-    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
-    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
-    cp_init.disconnect_on_fail             = false;
-    cp_init.evt_handler                    = on_conn_params_evt;
-    cp_init.error_handler                  = conn_params_error_handler;
-
-    err_code = ble_conn_params_init(&cp_init);
-    APP_ERROR_CHECK(err_code);
-}
-
-/**@brief Function for handling advertising events.
- *
- * @details This function will be called for advertising events which are passed to the application.
- *
- * @param[in] ble_adv_evt  Advertising event.
- */
-static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
-{
-    // uint32_t err_code;
-
-    switch (ble_adv_evt)
-    {
-        case BLE_ADV_EVT_FAST:
-            // err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
-            // APP_ERROR_CHECK(err_code);
-            stack_state = STACK_STATE_ADV;
-            rt_kprintf("fast advert\n");
-            break;
-        case BLE_ADV_EVT_IDLE:
-            // sleep_mode_enter();
-            stack_state = STACK_STATE_IDLE;
-            rt_kprintf("advert idle\n");
-            break;
-        default:
-            break;
-    }
-}
-
-
-/**@brief Function for the application's SoftDevice event handler.
- *
- * @param[in] p_ble_evt SoftDevice event.
- */
-static void on_ble_evt(ble_evt_t * p_ble_evt)
-{
-    uint32_t err_code;
-
-    switch (p_ble_evt->header.evt_id)
-    {
-        case BLE_GAP_EVT_CONNECTED:
-            // err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
-            // APP_ERROR_CHECK(err_code);
-            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
-            stack_state = STACK_STATE_CON;
-            rt_kprintf("Connected\r\n");
-            break; // BLE_GAP_EVT_CONNECTED
-
-        case BLE_GAP_EVT_DISCONNECTED:
-            // err_code = bsp_indication_set(BSP_INDICATE_IDLE);
-            // APP_ERROR_CHECK(err_code);
-            m_conn_handle = BLE_CONN_HANDLE_INVALID;
-            stack_state = STACK_STATE_DISC;
-            rt_kprintf("Disconnected\r\n");
-            break; // BLE_GAP_EVT_DISCONNECTED
-
-        case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
-            // Pairing not supported
-            err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
-            APP_ERROR_CHECK(err_code);
-            break; // BLE_GAP_EVT_SEC_PARAMS_REQUEST
-
-        case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
-        {
-            ble_gap_data_length_params_t dl_params;
-
-            // Clearing the struct will effectivly set members to @ref BLE_GAP_DATA_LENGTH_AUTO
-            memset(&dl_params, 0, sizeof(ble_gap_data_length_params_t));
-            err_code = sd_ble_gap_data_length_update(p_ble_evt->evt.gap_evt.conn_handle, &dl_params, NULL);
-            APP_ERROR_CHECK(err_code);
-        } break;
-
-        case BLE_GATTS_EVT_SYS_ATTR_MISSING:
-            // No system attributes have been stored.
-            err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
-            APP_ERROR_CHECK(err_code);
-            break; // BLE_GATTS_EVT_SYS_ATTR_MISSING
-
-        case BLE_GATTC_EVT_TIMEOUT:
-            // Disconnect on GATT Client timeout event.
-            err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
-                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
-            APP_ERROR_CHECK(err_code);
-            break; // BLE_GATTC_EVT_TIMEOUT
-
-        case BLE_GATTS_EVT_TIMEOUT:
-            // Disconnect on GATT Server timeout event.
-            err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
-                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
-            APP_ERROR_CHECK(err_code);
-            break; // BLE_GATTS_EVT_TIMEOUT
-
-        case BLE_EVT_USER_MEM_REQUEST:
-            err_code = sd_ble_user_mem_reply(p_ble_evt->evt.gattc_evt.conn_handle, NULL);
-            APP_ERROR_CHECK(err_code);
-            break; // BLE_EVT_USER_MEM_REQUEST
-
-        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
-        {
-            ble_gatts_evt_rw_authorize_request_t  req;
-            ble_gatts_rw_authorize_reply_params_t auth_reply;
-
-            req = p_ble_evt->evt.gatts_evt.params.authorize_request;
-
-            if (req.type != BLE_GATTS_AUTHORIZE_TYPE_INVALID)
-            {
-                if ((req.request.write.op == BLE_GATTS_OP_PREP_WRITE_REQ)     ||
-                    (req.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) ||
-                    (req.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL))
-                {
-                    if (req.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
-                    {
-                        auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
-                    }
-                    else
-                    {
-                        auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_READ;
-                    }
-                    auth_reply.params.write.gatt_status = APP_FEATURE_NOT_SUPPORTED;
-                    err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gatts_evt.conn_handle,
-                                                               &auth_reply);
-                    APP_ERROR_CHECK(err_code);
-                }
-            }
-        } break; // BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
-
-        default:
-            // No implementation needed.
-            break;
-    }
-}
-
-
-/**@brief Function for dispatching a SoftDevice event to all modules with a SoftDevice
- *        event handler.
- *
- * @details This function is called from the SoftDevice event interrupt handler after a
- *          SoftDevice event has been received.
- *
- * @param[in] p_ble_evt  SoftDevice event.
- */
-static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
-{
-    if (rt_mq_send(stack_evt_mq, p_ble_evt, p_ble_evt->header.evt_len) != RT_EOK)
-    {
-        rt_kprintf("dispatch malloc failure\n");
-    }
-    else
-    {
-        rt_event_send(stack_event, STACK_EV_DISPATCH);
-    }
-}
-
-static rt_err_t evt_dispatch_worker(void)
-{
-    ble_evt_t * p_ble_evt = (ble_evt_t *)evt_sample;
-    rt_err_t err;
-
-    err = rt_mq_recv(stack_evt_mq, (void*)evt_sample, BLE_STACK_EVT_MSG_BUF_SIZE, RT_WAITING_NO);
-
-    if (RT_EOK == err)
-    {
-        ble_conn_params_on_ble_evt(p_ble_evt);
-        nrf_ble_gatt_on_ble_evt(&m_gatt, p_ble_evt);
-        ble_nus_on_ble_evt(&m_nus, p_ble_evt);
-        on_ble_evt(p_ble_evt);
-        ble_advertising_on_ble_evt(p_ble_evt);
-        // bsp_btn_ble_on_ble_evt(p_ble_evt);
-
-        rt_kprintf("ble evt dispatch\n");
-    }
-
-    return err;
-}
-
-static uint32_t _softdevice_evt_schedule(void)
-{
-    rt_sem_release(sd_evt_sem);
-
-    return NRF_SUCCESS;
-}
-
-/**@brief Function for the SoftDevice initialization.
- *
- * @details This function initializes the SoftDevice and the BLE event interrupt.
- */
-static void ble_stack_init(void)
-{
-    uint32_t err_code;
-
-    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
-
-    // Initialize SoftDevice.
-    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, _softdevice_evt_schedule);
-
-    // Fetch the start address of the application RAM.
-    uint32_t ram_start = 0;
-    err_code = softdevice_app_ram_start_get(&ram_start);
-    APP_ERROR_CHECK(err_code);
-
-    // Overwrite some of the default configurations for the BLE stack.
-    ble_cfg_t ble_cfg;
-
-    // Configure the maximum number of connections.
-    memset(&ble_cfg, 0, sizeof(ble_cfg));
-    ble_cfg.gap_cfg.role_count_cfg.periph_role_count  = BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT;
-    ble_cfg.gap_cfg.role_count_cfg.central_role_count = 0;
-    ble_cfg.gap_cfg.role_count_cfg.central_sec_count  = 0;
-    err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, ram_start);
-    APP_ERROR_CHECK(err_code);
-
-    // Configure the maximum ATT MTU.
-    memset(&ble_cfg, 0x00, sizeof(ble_cfg));
-    ble_cfg.conn_cfg.conn_cfg_tag                 = CONN_CFG_TAG;
-    ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_BLE_GATT_MAX_MTU_SIZE;
-    err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start);
-    APP_ERROR_CHECK(err_code);
-
-    // Configure the maximum event length.
-    memset(&ble_cfg, 0x00, sizeof(ble_cfg));
-    ble_cfg.conn_cfg.conn_cfg_tag                     = CONN_CFG_TAG;
-    ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = 320;
-    ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count   = BLE_GAP_CONN_COUNT_DEFAULT;
-    err_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, ram_start);
-    APP_ERROR_CHECK(err_code);
-
-    // Enable BLE stack.
-    err_code = softdevice_enable(&ram_start);
-    APP_ERROR_CHECK(err_code);
-
-    // Subscribe for BLE events.
-    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
-    APP_ERROR_CHECK(err_code);
-}
-
-/**@brief Function for handling events from the GATT library. */
-static void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, const nrf_ble_gatt_evt_t * p_evt)
-{
-    if ((m_conn_handle == p_evt->conn_handle) && (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED))
-    {
-        m_ble_nus_max_data_len = p_evt->params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH;
-        rt_kprintf("Data len is set to 0x%X(%d)\r\n", m_ble_nus_max_data_len, m_ble_nus_max_data_len);
-    }
-    rt_kprintf("ATT MTU exchange completed. central 0x%x peripheral 0x%x\r\n", p_gatt->att_mtu_desired_central, p_gatt->att_mtu_desired_periph);
-}
-
-/**@brief Function for initializing the GATT library. */
-static void gatt_init(void)
-{
-    ret_code_t err_code;
-
-    err_code = nrf_ble_gatt_init(&m_gatt, gatt_evt_handler);
-    APP_ERROR_CHECK(err_code);
-
-    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, 64);
-    APP_ERROR_CHECK(err_code);
-}
-
-/**@brief Function for initializing the Advertising functionality.
- */
-static void advertising_init(void)
-{
-    uint32_t               err_code;
-    ble_advdata_t          advdata;
-    ble_advdata_t          scanrsp;
-    ble_adv_modes_config_t options;
-
-    // Build advertising data struct to pass into @ref ble_advertising_init.
-    memset(&advdata, 0, sizeof(advdata));
-    advdata.name_type          = BLE_ADVDATA_FULL_NAME;
-    advdata.include_appearance = false;
-    advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
-
-    memset(&scanrsp, 0, sizeof(scanrsp));
-    scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
-    scanrsp.uuids_complete.p_uuids  = m_adv_uuids;
-
-    memset(&options, 0, sizeof(options));
-    options.ble_adv_fast_enabled  = true;
-    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
-    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
-
-    err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
-    APP_ERROR_CHECK(err_code);
-
-    ble_advertising_conn_cfg_tag_set(CONN_CFG_TAG);
-}
-
-/**@brief   Function for handling app_uart events.
- *
- * @details This function will receive a single character from the app_uart module and append it to
- *          a string. The string will be be sent over BLE when the last character received was a
- *          'new line' '\n' (hex 0x0A) or if the string has reached the maximum data length.
- */
-/**@snippet [Handling the data received over UART] */
-void uart_event_handle(rt_device_t uart)
-{
-    uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
-    rt_size_t size = 0;
-    uint32_t       err_code;
-
-    size = rt_device_read(uart, 0, data_array, BLE_NUS_MAX_DATA_LEN);
-
-    if (size <= 0)
-    {
-        return;
-    }
-
-    do
-    {
-        err_code = ble_nus_string_send(&m_nus, data_array, size);
-        if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY) )
-        {
-            APP_ERROR_CHECK(err_code);
-        }
-    } while (err_code == NRF_ERROR_BUSY);
-}
-/**@snippet [Handling the data received over UART] */
-
-/**@brief  Function for initializing the UART module.
- */
-/**@snippet [UART Initialization] */
-static rt_bool_t _stack_init(void)
-{
-    uint32_t err_code;
-
-    stack_event = rt_event_create("stackev", RT_IPC_FLAG_FIFO);
-    sd_evt_sem = rt_sem_create("sdsem", 0, RT_IPC_FLAG_FIFO);
-    stack_evt_mq = rt_mq_create("stackmq", BLE_STACK_EVT_MSG_BUF_SIZE, STACK_EVT_MQ_NUM, RT_IPC_FLAG_FIFO);
-    evt_sample = rt_malloc(BLE_STACK_EVT_MSG_BUF_SIZE);
-
-    if (!stack_event || !sd_evt_sem || !stack_evt_mq || !evt_sample)
-    {
-        rt_kprintf("uart rx sem create failure\n");
-        return RT_FALSE;
-    }
-
-    // Initialize.
-    err_code = app_timer_init();
-    APP_ERROR_CHECK(err_code);
-
-    ble_stack_init();
-    gap_params_init();
-    gatt_init();
-    services_init();
-    advertising_init();
-    conn_params_init();
-
-    return RT_TRUE;
-}
-
-/**@brief Application main function.
- */
-static void _stack_thread(void *parameter)
-{
-    rt_tick_t next_timeout = (rt_tick_t)RT_WAITING_FOREVER;
-
-    FAST_ADV();
-    // Enter main loop.
-    for (;;)
-    {
-        rt_uint32_t event = 0;
-        rt_tick_t dispatch_timeout = RT_WAITING_NO;
-
-        rt_event_recv(stack_event, STACK_EV_DISCON | STACK_EV_DISPATCH | STACK_EV_KEY,
-                    RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, next_timeout, &event);
-
-        if (evt_dispatch_worker() != RT_EOK)
-        {
-            dispatch_timeout = (rt_tick_t)RT_WAITING_FOREVER;
-        }
-
-        if (event & STACK_EV_DISCON)
-        {
-            if (BLE_CONN_HANDLE_INVALID != m_conn_handle)
-            {
-                sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
-            }
-        }
-
-        if (event & STACK_EV_KEY)
-        {
-            if (stack_state != STACK_STATE_CON && stack_state != STACK_STATE_ADV)
-            {
-                FAST_ADV();
-            }
-        }
-
-        next_timeout = (rt_tick_t)RT_WAITING_FOREVER;
-
-        if (dispatch_timeout < next_timeout)
-        {
-            next_timeout = dispatch_timeout;
-        }
-    }
-}
-
-static void _softdevice_thread(void* parameter)
-{
-    for (;;)
-    {
-        rt_sem_take(sd_evt_sem, RT_WAITING_FOREVER);
-        intern_softdevice_events_execute();
-    }
-}
-
-rt_err_t ble_init(void)
-{
-    rt_thread_t thread;
-
-    _stack_init();
-
-    thread = rt_thread_create("sdth", _softdevice_thread, RT_NULL, 512, 0, 10);
-
-    if (thread != RT_NULL)
-    {
-        rt_thread_startup(thread);
-    }
-    else
-    {
-        return RT_ERROR;
-    }
-
-    thread = rt_thread_create("bleth", _stack_thread, RT_NULL, 2048, 1, 10);
-
-    if (thread != RT_NULL)
-    {
-        return rt_thread_startup(thread);
-    }
-
-    return RT_ERROR;
-}

+ 0 - 3991
bsp/nrf52832/applications/sdk_config.h

@@ -1,3991 +0,0 @@
-
-
-#ifndef SDK_CONFIG_H
-#define SDK_CONFIG_H
-// <<< Use Configuration Wizard in Context Menu >>>\n
-#ifdef USE_APP_CONFIG
-#include "app_config.h"
-#endif
-// <h> nRF_BLE
-
-//==========================================================
-// <q> BLE_ADVERTISING_ENABLED  - ble_advertising - Advertising module
-
-
-#ifndef BLE_ADVERTISING_ENABLED
-#define BLE_ADVERTISING_ENABLED 1
-#endif
-
-// <q> BLE_DTM_ENABLED  - ble_dtm - Module for testing RF/PHY using DTM commands
-
-
-#ifndef BLE_DTM_ENABLED
-#define BLE_DTM_ENABLED 0
-#endif
-
-// <q> BLE_RACP_ENABLED  - ble_racp - Record Access Control Point library
-
-
-#ifndef BLE_RACP_ENABLED
-#define BLE_RACP_ENABLED 0
-#endif
-
-// <e> NRF_BLE_GATT_ENABLED - nrf_ble_gatt - GATT module
-//==========================================================
-#ifndef NRF_BLE_GATT_ENABLED
-#define NRF_BLE_GATT_ENABLED 1
-#endif
-#if  NRF_BLE_GATT_ENABLED
-// <o> NRF_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size that is passed to the @ref sd_ble_enable function.
-#ifndef NRF_BLE_GATT_MAX_MTU_SIZE
-#define NRF_BLE_GATT_MAX_MTU_SIZE 158
-#endif
-
-#endif //NRF_BLE_GATT_ENABLED
-// </e>
-
-// <q> NRF_BLE_QWR_ENABLED  - nrf_ble_qwr - Queued writes support module (prepare/execute write)
-
-
-#ifndef NRF_BLE_QWR_ENABLED
-#define NRF_BLE_QWR_ENABLED 0
-#endif
-
-// <q> PEER_MANAGER_ENABLED  - peer_manager - Peer Manager
-
-
-#ifndef PEER_MANAGER_ENABLED
-#define PEER_MANAGER_ENABLED 0
-#endif
-
-// </h>
-//==========================================================
-
-// <h> nRF_BLE_Services
-
-//==========================================================
-// <q> BLE_ANCS_C_ENABLED  - ble_ancs_c - Apple Notification Service Client
-
-
-#ifndef BLE_ANCS_C_ENABLED
-#define BLE_ANCS_C_ENABLED 0
-#endif
-
-// <q> BLE_ANS_C_ENABLED  - ble_ans_c - Alert Notification Service Client
-
-
-#ifndef BLE_ANS_C_ENABLED
-#define BLE_ANS_C_ENABLED 0
-#endif
-
-// <q> BLE_BAS_C_ENABLED  - ble_bas_c - Battery Service Client
-
-
-#ifndef BLE_BAS_C_ENABLED
-#define BLE_BAS_C_ENABLED 0
-#endif
-
-// <q> BLE_BAS_ENABLED  - ble_bas - Battery Service
-
-
-#ifndef BLE_BAS_ENABLED
-#define BLE_BAS_ENABLED 0
-#endif
-
-// <q> BLE_CSCS_ENABLED  - ble_cscs - Cycling Speed and Cadence Service
-
-
-#ifndef BLE_CSCS_ENABLED
-#define BLE_CSCS_ENABLED 0
-#endif
-
-// <q> BLE_CTS_C_ENABLED  - ble_cts_c - Current Time Service Client
-
-
-#ifndef BLE_CTS_C_ENABLED
-#define BLE_CTS_C_ENABLED 0
-#endif
-
-// <q> BLE_DIS_ENABLED  - ble_dis - Device Information Service
-
-
-#ifndef BLE_DIS_ENABLED
-#define BLE_DIS_ENABLED 0
-#endif
-
-// <q> BLE_GLS_ENABLED  - ble_gls - Glucose Service
-
-
-#ifndef BLE_GLS_ENABLED
-#define BLE_GLS_ENABLED 0
-#endif
-
-// <q> BLE_HIDS_ENABLED  - ble_hids - Human Interface Device Service
-
-
-#ifndef BLE_HIDS_ENABLED
-#define BLE_HIDS_ENABLED 0
-#endif
-
-// <e> BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client
-//==========================================================
-#ifndef BLE_HRS_C_ENABLED
-#define BLE_HRS_C_ENABLED 0
-#endif
-#if  BLE_HRS_C_ENABLED
-// <o> BLE_HRS_C_RR_INTERVALS_MAX_CNT - Maximum number of RR_INTERVALS per notification to be decoded
-#ifndef BLE_HRS_C_RR_INTERVALS_MAX_CNT
-#define BLE_HRS_C_RR_INTERVALS_MAX_CNT 30
-#endif
-
-#endif //BLE_HRS_C_ENABLED
-// </e>
-
-// <q> BLE_HRS_ENABLED  - ble_hrs - Heart Rate Service
-
-
-#ifndef BLE_HRS_ENABLED
-#define BLE_HRS_ENABLED 0
-#endif
-
-// <q> BLE_HTS_ENABLED  - ble_hts - Health Thermometer Service
-
-
-#ifndef BLE_HTS_ENABLED
-#define BLE_HTS_ENABLED 0
-#endif
-
-// <q> BLE_IAS_C_ENABLED  - ble_ias_c - Immediate Alert Service Client
-
-
-#ifndef BLE_IAS_C_ENABLED
-#define BLE_IAS_C_ENABLED 0
-#endif
-
-// <q> BLE_IAS_ENABLED  - ble_ias - Immediate Alert Service
-
-
-#ifndef BLE_IAS_ENABLED
-#define BLE_IAS_ENABLED 0
-#endif
-
-// <q> BLE_LBS_C_ENABLED  - ble_lbs_c - Nordic LED Button Service Client
-
-
-#ifndef BLE_LBS_C_ENABLED
-#define BLE_LBS_C_ENABLED 0
-#endif
-
-// <q> BLE_LBS_ENABLED  - ble_lbs - LED Button Service
-
-
-#ifndef BLE_LBS_ENABLED
-#define BLE_LBS_ENABLED 0
-#endif
-
-// <q> BLE_LLS_ENABLED  - ble_lls - Link Loss Service
-
-
-#ifndef BLE_LLS_ENABLED
-#define BLE_LLS_ENABLED 0
-#endif
-
-// <q> BLE_NUS_C_ENABLED  - ble_nus_c - Nordic UART Central Service
-
-
-#ifndef BLE_NUS_C_ENABLED
-#define BLE_NUS_C_ENABLED 0
-#endif
-
-// <q> BLE_NUS_ENABLED  - ble_nus - Nordic UART Service
-
-
-#ifndef BLE_NUS_ENABLED
-#define BLE_NUS_ENABLED 1
-#endif
-
-// <q> BLE_RSCS_C_ENABLED  - ble_rscs_c - Running Speed and Cadence Client
-
-
-#ifndef BLE_RSCS_C_ENABLED
-#define BLE_RSCS_C_ENABLED 0
-#endif
-
-// <q> BLE_RSCS_ENABLED  - ble_rscs - Running Speed and Cadence Service
-
-
-#ifndef BLE_RSCS_ENABLED
-#define BLE_RSCS_ENABLED 0
-#endif
-
-// <q> BLE_TPS_ENABLED  - ble_tps - TX Power Service
-
-
-#ifndef BLE_TPS_ENABLED
-#define BLE_TPS_ENABLED 0
-#endif
-
-// </h>
-//==========================================================
-
-// <h> nRF_Drivers
-
-//==========================================================
-// <e> APP_USBD_ENABLED - app_usbd - USB Device library
-//==========================================================
-#ifndef APP_USBD_ENABLED
-#define APP_USBD_ENABLED 0
-#endif
-#if  APP_USBD_ENABLED
-// <o> APP_USBD_VID - Vendor ID  <0x0000-0xFFFF>
-
-
-// <i> Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/
-
-#ifndef APP_USBD_VID
-#define APP_USBD_VID 0
-#endif
-
-// <o> APP_USBD_PID - Product ID  <0x0000-0xFFFF>
-
-
-// <i> Selected Product ID
-
-#ifndef APP_USBD_PID
-#define APP_USBD_PID 0
-#endif
-
-// <o> APP_USBD_DEVICE_VER_MAJOR - Device version, major part  <0-99>
-
-
-// <i> Device version, will be converted automatically to BCD notation. Use just decimal values.
-
-#ifndef APP_USBD_DEVICE_VER_MAJOR
-#define APP_USBD_DEVICE_VER_MAJOR 1
-#endif
-
-// <o> APP_USBD_DEVICE_VER_MINOR - Device version, minor part  <0-99>
-
-
-// <i> Device version, will be converted automatically to BCD notation. Use just decimal values.
-
-#ifndef APP_USBD_DEVICE_VER_MINOR
-#define APP_USBD_DEVICE_VER_MINOR 0
-#endif
-
-#endif //APP_USBD_ENABLED
-// </e>
-
-// <e> CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver
-//==========================================================
-#ifndef CLOCK_ENABLED
-#define CLOCK_ENABLED 1
-#endif
-#if  CLOCK_ENABLED
-// <o> CLOCK_CONFIG_XTAL_FREQ  - HF XTAL Frequency
-
-// <0=> Default (64 MHz)
-
-#ifndef CLOCK_CONFIG_XTAL_FREQ
-#define CLOCK_CONFIG_XTAL_FREQ 0
-#endif
-
-// <o> CLOCK_CONFIG_LF_SRC  - LF Clock Source
-
-// <0=> RC
-// <1=> XTAL
-// <2=> Synth
-
-#ifndef CLOCK_CONFIG_LF_SRC
-#define CLOCK_CONFIG_LF_SRC 1
-#endif
-
-// <o> CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef CLOCK_CONFIG_IRQ_PRIORITY
-#define CLOCK_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef CLOCK_CONFIG_LOG_ENABLED
-#define CLOCK_CONFIG_LOG_ENABLED 0
-#endif
-#if  CLOCK_CONFIG_LOG_ENABLED
-// <o> CLOCK_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef CLOCK_CONFIG_LOG_LEVEL
-#define CLOCK_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> CLOCK_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef CLOCK_CONFIG_INFO_COLOR
-#define CLOCK_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> CLOCK_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef CLOCK_CONFIG_DEBUG_COLOR
-#define CLOCK_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //CLOCK_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //CLOCK_ENABLED
-// </e>
-
-// <e> COMP_ENABLED - nrf_drv_comp - COMP peripheral driver
-//==========================================================
-#ifndef COMP_ENABLED
-#define COMP_ENABLED 0
-#endif
-#if  COMP_ENABLED
-// <o> COMP_CONFIG_REF  - Reference voltage
-
-// <0=> Internal 1.2V
-// <1=> Internal 1.8V
-// <2=> Internal 2.4V
-// <4=> VDD
-// <7=> ARef
-
-#ifndef COMP_CONFIG_REF
-#define COMP_CONFIG_REF 1
-#endif
-
-// <o> COMP_CONFIG_MAIN_MODE  - Main mode
-
-// <0=> Single ended
-// <1=> Differential
-
-#ifndef COMP_CONFIG_MAIN_MODE
-#define COMP_CONFIG_MAIN_MODE 0
-#endif
-
-// <o> COMP_CONFIG_SPEED_MODE  - Speed mode
-
-// <0=> Low power
-// <1=> Normal
-// <2=> High speed
-
-#ifndef COMP_CONFIG_SPEED_MODE
-#define COMP_CONFIG_SPEED_MODE 2
-#endif
-
-// <o> COMP_CONFIG_HYST  - Hystheresis
-
-// <0=> No
-// <1=> 50mV
-
-#ifndef COMP_CONFIG_HYST
-#define COMP_CONFIG_HYST 0
-#endif
-
-// <o> COMP_CONFIG_ISOURCE  - Current Source
-
-// <0=> Off
-// <1=> 2.5 uA
-// <2=> 5 uA
-// <3=> 10 uA
-
-#ifndef COMP_CONFIG_ISOURCE
-#define COMP_CONFIG_ISOURCE 0
-#endif
-
-// <o> COMP_CONFIG_INPUT  - Analog input
-
-// <0=> 0
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef COMP_CONFIG_INPUT
-#define COMP_CONFIG_INPUT 0
-#endif
-
-// <o> COMP_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef COMP_CONFIG_IRQ_PRIORITY
-#define COMP_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> COMP_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef COMP_CONFIG_LOG_ENABLED
-#define COMP_CONFIG_LOG_ENABLED 0
-#endif
-#if  COMP_CONFIG_LOG_ENABLED
-// <o> COMP_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef COMP_CONFIG_LOG_LEVEL
-#define COMP_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> COMP_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef COMP_CONFIG_INFO_COLOR
-#define COMP_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> COMP_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef COMP_CONFIG_DEBUG_COLOR
-#define COMP_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //COMP_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //COMP_ENABLED
-// </e>
-
-// <e> EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver
-//==========================================================
-#ifndef EGU_ENABLED
-#define EGU_ENABLED 0
-#endif
-#if  EGU_ENABLED
-// <e> SWI_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef SWI_CONFIG_LOG_ENABLED
-#define SWI_CONFIG_LOG_ENABLED 0
-#endif
-#if  SWI_CONFIG_LOG_ENABLED
-// <o> SWI_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef SWI_CONFIG_LOG_LEVEL
-#define SWI_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> SWI_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef SWI_CONFIG_INFO_COLOR
-#define SWI_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> SWI_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef SWI_CONFIG_DEBUG_COLOR
-#define SWI_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //SWI_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //EGU_ENABLED
-// </e>
-
-// <e> GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver
-//==========================================================
-#ifndef GPIOTE_ENABLED
-#define GPIOTE_ENABLED 1
-#endif
-#if  GPIOTE_ENABLED
-// <o> GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins
-#ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
-#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4
-#endif
-
-// <o> GPIOTE_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef GPIOTE_CONFIG_IRQ_PRIORITY
-#define GPIOTE_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef GPIOTE_CONFIG_LOG_ENABLED
-#define GPIOTE_CONFIG_LOG_ENABLED 0
-#endif
-#if  GPIOTE_CONFIG_LOG_ENABLED
-// <o> GPIOTE_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef GPIOTE_CONFIG_LOG_LEVEL
-#define GPIOTE_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> GPIOTE_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef GPIOTE_CONFIG_INFO_COLOR
-#define GPIOTE_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> GPIOTE_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef GPIOTE_CONFIG_DEBUG_COLOR
-#define GPIOTE_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //GPIOTE_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //GPIOTE_ENABLED
-// </e>
-
-// <e> I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver
-//==========================================================
-#ifndef I2S_ENABLED
-#define I2S_ENABLED 0
-#endif
-#if  I2S_ENABLED
-// <o> I2S_CONFIG_SCK_PIN - SCK pin  <0-31>
-
-
-#ifndef I2S_CONFIG_SCK_PIN
-#define I2S_CONFIG_SCK_PIN 31
-#endif
-
-// <o> I2S_CONFIG_LRCK_PIN - LRCK pin  <1-31>
-
-
-#ifndef I2S_CONFIG_LRCK_PIN
-#define I2S_CONFIG_LRCK_PIN 30
-#endif
-
-// <o> I2S_CONFIG_MCK_PIN - MCK pin
-#ifndef I2S_CONFIG_MCK_PIN
-#define I2S_CONFIG_MCK_PIN 255
-#endif
-
-// <o> I2S_CONFIG_SDOUT_PIN - SDOUT pin  <0-31>
-
-
-#ifndef I2S_CONFIG_SDOUT_PIN
-#define I2S_CONFIG_SDOUT_PIN 29
-#endif
-
-// <o> I2S_CONFIG_SDIN_PIN - SDIN pin  <0-31>
-
-
-#ifndef I2S_CONFIG_SDIN_PIN
-#define I2S_CONFIG_SDIN_PIN 28
-#endif
-
-// <o> I2S_CONFIG_MASTER  - Mode
-
-// <0=> Master
-// <1=> Slave
-
-#ifndef I2S_CONFIG_MASTER
-#define I2S_CONFIG_MASTER 0
-#endif
-
-// <o> I2S_CONFIG_FORMAT  - Format
-
-// <0=> I2S
-// <1=> Aligned
-
-#ifndef I2S_CONFIG_FORMAT
-#define I2S_CONFIG_FORMAT 0
-#endif
-
-// <o> I2S_CONFIG_ALIGN  - Alignment
-
-// <0=> Left
-// <1=> Right
-
-#ifndef I2S_CONFIG_ALIGN
-#define I2S_CONFIG_ALIGN 0
-#endif
-
-// <o> I2S_CONFIG_SWIDTH  - Sample width (bits)
-
-// <0=> 8
-// <1=> 16
-// <2=> 24
-
-#ifndef I2S_CONFIG_SWIDTH
-#define I2S_CONFIG_SWIDTH 1
-#endif
-
-// <o> I2S_CONFIG_CHANNELS  - Channels
-
-// <0=> Stereo
-// <1=> Left
-// <2=> Right
-
-#ifndef I2S_CONFIG_CHANNELS
-#define I2S_CONFIG_CHANNELS 1
-#endif
-
-// <o> I2S_CONFIG_MCK_SETUP  - MCK behavior
-
-// <0=> Disabled
-// <2147483648=> 32MHz/2
-// <1342177280=> 32MHz/3
-// <1073741824=> 32MHz/4
-// <805306368=> 32MHz/5
-// <671088640=> 32MHz/6
-// <536870912=> 32MHz/8
-// <402653184=> 32MHz/10
-// <369098752=> 32MHz/11
-// <285212672=> 32MHz/15
-// <268435456=> 32MHz/16
-// <201326592=> 32MHz/21
-// <184549376=> 32MHz/23
-// <142606336=> 32MHz/30
-// <138412032=> 32MHz/31
-// <134217728=> 32MHz/32
-// <100663296=> 32MHz/42
-// <68157440=> 32MHz/63
-// <34340864=> 32MHz/125
-
-#ifndef I2S_CONFIG_MCK_SETUP
-#define I2S_CONFIG_MCK_SETUP 536870912
-#endif
-
-// <o> I2S_CONFIG_RATIO  - MCK/LRCK ratio
-
-// <0=> 32x
-// <1=> 48x
-// <2=> 64x
-// <3=> 96x
-// <4=> 128x
-// <5=> 192x
-// <6=> 256x
-// <7=> 384x
-// <8=> 512x
-
-#ifndef I2S_CONFIG_RATIO
-#define I2S_CONFIG_RATIO 2000
-#endif
-
-// <o> I2S_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef I2S_CONFIG_IRQ_PRIORITY
-#define I2S_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> I2S_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef I2S_CONFIG_LOG_ENABLED
-#define I2S_CONFIG_LOG_ENABLED 0
-#endif
-#if  I2S_CONFIG_LOG_ENABLED
-// <o> I2S_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef I2S_CONFIG_LOG_LEVEL
-#define I2S_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> I2S_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef I2S_CONFIG_INFO_COLOR
-#define I2S_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> I2S_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef I2S_CONFIG_DEBUG_COLOR
-#define I2S_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //I2S_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //I2S_ENABLED
-// </e>
-
-// <e> LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver
-//==========================================================
-#ifndef LPCOMP_ENABLED
-#define LPCOMP_ENABLED 0
-#endif
-#if  LPCOMP_ENABLED
-// <o> LPCOMP_CONFIG_REFERENCE  - Reference voltage
-
-// <0=> Supply 1/8
-// <1=> Supply 2/8
-// <2=> Supply 3/8
-// <3=> Supply 4/8
-// <4=> Supply 5/8
-// <5=> Supply 6/8
-// <6=> Supply 7/8
-// <8=> Supply 1/16 (nRF52)
-// <9=> Supply 3/16 (nRF52)
-// <10=> Supply 5/16 (nRF52)
-// <11=> Supply 7/16 (nRF52)
-// <12=> Supply 9/16 (nRF52)
-// <13=> Supply 11/16 (nRF52)
-// <14=> Supply 13/16 (nRF52)
-// <15=> Supply 15/16 (nRF52)
-// <7=> External Ref 0
-// <65543=> External Ref 1
-
-#ifndef LPCOMP_CONFIG_REFERENCE
-#define LPCOMP_CONFIG_REFERENCE 3
-#endif
-
-// <o> LPCOMP_CONFIG_DETECTION  - Detection
-
-// <0=> Crossing
-// <1=> Up
-// <2=> Down
-
-#ifndef LPCOMP_CONFIG_DETECTION
-#define LPCOMP_CONFIG_DETECTION 2
-#endif
-
-// <o> LPCOMP_CONFIG_INPUT  - Analog input
-
-// <0=> 0
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef LPCOMP_CONFIG_INPUT
-#define LPCOMP_CONFIG_INPUT 0
-#endif
-
-// <q> LPCOMP_CONFIG_HYST  - Hysteresis
-
-
-#ifndef LPCOMP_CONFIG_HYST
-#define LPCOMP_CONFIG_HYST 0
-#endif
-
-// <o> LPCOMP_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef LPCOMP_CONFIG_IRQ_PRIORITY
-#define LPCOMP_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef LPCOMP_CONFIG_LOG_ENABLED
-#define LPCOMP_CONFIG_LOG_ENABLED 0
-#endif
-#if  LPCOMP_CONFIG_LOG_ENABLED
-// <o> LPCOMP_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef LPCOMP_CONFIG_LOG_LEVEL
-#define LPCOMP_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> LPCOMP_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef LPCOMP_CONFIG_INFO_COLOR
-#define LPCOMP_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> LPCOMP_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef LPCOMP_CONFIG_DEBUG_COLOR
-#define LPCOMP_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //LPCOMP_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //LPCOMP_ENABLED
-// </e>
-
-// <e> PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver
-//==========================================================
-#ifndef PDM_ENABLED
-#define PDM_ENABLED 0
-#endif
-#if  PDM_ENABLED
-// <o> PDM_CONFIG_MODE  - Mode
-
-// <0=> Stereo
-// <1=> Mono
-
-#ifndef PDM_CONFIG_MODE
-#define PDM_CONFIG_MODE 1
-#endif
-
-// <o> PDM_CONFIG_EDGE  - Edge
-
-// <0=> Left falling
-// <1=> Left rising
-
-#ifndef PDM_CONFIG_EDGE
-#define PDM_CONFIG_EDGE 0
-#endif
-
-// <o> PDM_CONFIG_CLOCK_FREQ  - Clock frequency
-
-// <134217728=> 1000k
-// <138412032=> 1032k (default)
-// <142606336=> 1067k
-
-#ifndef PDM_CONFIG_CLOCK_FREQ
-#define PDM_CONFIG_CLOCK_FREQ 138412032
-#endif
-
-// <o> PDM_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef PDM_CONFIG_IRQ_PRIORITY
-#define PDM_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> PDM_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef PDM_CONFIG_LOG_ENABLED
-#define PDM_CONFIG_LOG_ENABLED 0
-#endif
-#if  PDM_CONFIG_LOG_ENABLED
-// <o> PDM_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef PDM_CONFIG_LOG_LEVEL
-#define PDM_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> PDM_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef PDM_CONFIG_INFO_COLOR
-#define PDM_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> PDM_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef PDM_CONFIG_DEBUG_COLOR
-#define PDM_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //PDM_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //PDM_ENABLED
-// </e>
-
-// <e> PERIPHERAL_RESOURCE_SHARING_ENABLED - nrf_drv_common - Peripheral drivers common module
-//==========================================================
-#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED
-#define PERIPHERAL_RESOURCE_SHARING_ENABLED 0
-#endif
-#if  PERIPHERAL_RESOURCE_SHARING_ENABLED
-// <e> COMMON_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef COMMON_CONFIG_LOG_ENABLED
-#define COMMON_CONFIG_LOG_ENABLED 0
-#endif
-#if  COMMON_CONFIG_LOG_ENABLED
-// <o> COMMON_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef COMMON_CONFIG_LOG_LEVEL
-#define COMMON_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> COMMON_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef COMMON_CONFIG_INFO_COLOR
-#define COMMON_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> COMMON_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef COMMON_CONFIG_DEBUG_COLOR
-#define COMMON_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //COMMON_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //PERIPHERAL_RESOURCE_SHARING_ENABLED
-// </e>
-
-// <e> POWER_ENABLED - nrf_drv_power - POWER peripheral driver
-//==========================================================
-#ifndef POWER_ENABLED
-#define POWER_ENABLED 0
-#endif
-#if  POWER_ENABLED
-// <o> POWER_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef POWER_CONFIG_IRQ_PRIORITY
-#define POWER_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <q> POWER_CONFIG_DEFAULT_DCDCEN  - The default configuration of main DCDC regulator
-
-
-// <i> This settings means only that components for DCDC regulator are installed and it can be enabled.
-
-#ifndef POWER_CONFIG_DEFAULT_DCDCEN
-#define POWER_CONFIG_DEFAULT_DCDCEN 0
-#endif
-
-// <q> POWER_CONFIG_DEFAULT_DCDCENHV  - The default configuration of High Voltage DCDC regulator
-
-
-// <i> This settings means only that components for DCDC regulator are installed and it can be enabled.
-
-#ifndef POWER_CONFIG_DEFAULT_DCDCENHV
-#define POWER_CONFIG_DEFAULT_DCDCENHV 0
-#endif
-
-#endif //POWER_ENABLED
-// </e>
-
-// <e> PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver
-//==========================================================
-#ifndef PPI_ENABLED
-#define PPI_ENABLED 0
-#endif
-#if  PPI_ENABLED
-// <e> PPI_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef PPI_CONFIG_LOG_ENABLED
-#define PPI_CONFIG_LOG_ENABLED 0
-#endif
-#if  PPI_CONFIG_LOG_ENABLED
-// <o> PPI_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef PPI_CONFIG_LOG_LEVEL
-#define PPI_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> PPI_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef PPI_CONFIG_INFO_COLOR
-#define PPI_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> PPI_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef PPI_CONFIG_DEBUG_COLOR
-#define PPI_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //PPI_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //PPI_ENABLED
-// </e>
-
-// <e> PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver
-//==========================================================
-#ifndef PWM_ENABLED
-#define PWM_ENABLED 1
-#endif
-#if  PWM_ENABLED
-// <o> PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin  <0-31>
-
-
-#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN
-#define PWM_DEFAULT_CONFIG_OUT0_PIN 2
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin  <0-31>
-
-
-#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN
-#define PWM_DEFAULT_CONFIG_OUT1_PIN 31
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin  <0-31>
-
-
-#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN
-#define PWM_DEFAULT_CONFIG_OUT2_PIN 31
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin  <0-31>
-
-
-#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN
-#define PWM_DEFAULT_CONFIG_OUT3_PIN 31
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_BASE_CLOCK  - Base clock
-
-// <0=> 16 MHz
-// <1=> 8 MHz
-// <2=> 4 MHz
-// <3=> 2 MHz
-// <4=> 1 MHz
-// <5=> 500 kHz
-// <6=> 250 kHz
-// <7=> 125 MHz
-
-#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK
-#define PWM_DEFAULT_CONFIG_BASE_CLOCK 7
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_COUNT_MODE  - Count mode
-
-// <0=> Up
-// <1=> Up and Down
-
-#ifndef PWM_DEFAULT_CONFIG_COUNT_MODE
-#define PWM_DEFAULT_CONFIG_COUNT_MODE 0
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_TOP_VALUE - Top value
-#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE
-#define PWM_DEFAULT_CONFIG_TOP_VALUE 46
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_LOAD_MODE  - Load mode
-
-// <0=> Common
-// <1=> Grouped
-// <2=> Individual
-// <3=> Waveform
-
-#ifndef PWM_DEFAULT_CONFIG_LOAD_MODE
-#define PWM_DEFAULT_CONFIG_LOAD_MODE 0
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_STEP_MODE  - Step mode
-
-// <0=> Auto
-// <1=> Triggered
-
-#ifndef PWM_DEFAULT_CONFIG_STEP_MODE
-#define PWM_DEFAULT_CONFIG_STEP_MODE 0
-#endif
-
-// <o> PWM_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef PWM_DEFAULT_CONFIG_IRQ_PRIORITY
-#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <q> PWM0_ENABLED  - Enable PWM0 instance
-
-
-#ifndef PWM0_ENABLED
-#define PWM0_ENABLED 1
-#endif
-
-// <q> PWM1_ENABLED  - Enable PWM1 instance
-
-
-#ifndef PWM1_ENABLED
-#define PWM1_ENABLED 0
-#endif
-
-// <q> PWM2_ENABLED  - Enable PWM2 instance
-
-
-#ifndef PWM2_ENABLED
-#define PWM2_ENABLED 0
-#endif
-
-// <e> PWM_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef PWM_CONFIG_LOG_ENABLED
-#define PWM_CONFIG_LOG_ENABLED 0
-#endif
-#if  PWM_CONFIG_LOG_ENABLED
-// <o> PWM_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef PWM_CONFIG_LOG_LEVEL
-#define PWM_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> PWM_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef PWM_CONFIG_INFO_COLOR
-#define PWM_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> PWM_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef PWM_CONFIG_DEBUG_COLOR
-#define PWM_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //PWM_CONFIG_LOG_ENABLED
-// </e>
-
-// <e> PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM.
-
-// <i> The workaround uses interrupts to wake up the CPU and ensure
-// <i> it is active when PWM is about to start a DMA transfer. For
-// <i> initial transfer, done when a playback is started via PPI,
-// <i> a specific EGU instance is used to generate the interrupt.
-// <i> During the playback, the PWM interrupt triggered on SEQEND
-// <i> event of a preceding sequence is used to protect the transfer
-// <i> done for the next sequence to be played.
-//==========================================================
-#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED
-#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0
-#endif
-#if  PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED
-// <o> PWM_NRF52_ANOMALY_109_EGU_INSTANCE  - EGU instance used by the nRF52 Anomaly 109 workaround for PWM.
-
-// <0=> EGU0
-// <1=> EGU1
-// <2=> EGU2
-// <3=> EGU3
-// <4=> EGU4
-// <5=> EGU5
-
-#ifndef PWM_NRF52_ANOMALY_109_EGU_INSTANCE
-#define PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5
-#endif
-
-#endif //PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED
-// </e>
-
-#endif //PWM_ENABLED
-// </e>
-
-// <e> QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver
-//==========================================================
-#ifndef QDEC_ENABLED
-#define QDEC_ENABLED 0
-#endif
-#if  QDEC_ENABLED
-// <o> QDEC_CONFIG_REPORTPER  - Report period
-
-// <0=> 10 Samples
-// <1=> 40 Samples
-// <2=> 80 Samples
-// <3=> 120 Samples
-// <4=> 160 Samples
-// <5=> 200 Samples
-// <6=> 240 Samples
-// <7=> 280 Samples
-
-#ifndef QDEC_CONFIG_REPORTPER
-#define QDEC_CONFIG_REPORTPER 0
-#endif
-
-// <o> QDEC_CONFIG_SAMPLEPER  - Sample period
-
-// <0=> 128 us
-// <1=> 256 us
-// <2=> 512 us
-// <3=> 1024 us
-// <4=> 2048 us
-// <5=> 4096 us
-// <6=> 8192 us
-// <7=> 16384 us
-
-#ifndef QDEC_CONFIG_SAMPLEPER
-#define QDEC_CONFIG_SAMPLEPER 7
-#endif
-
-// <o> QDEC_CONFIG_PIO_A - A pin  <0-31>
-
-
-#ifndef QDEC_CONFIG_PIO_A
-#define QDEC_CONFIG_PIO_A 31
-#endif
-
-// <o> QDEC_CONFIG_PIO_B - B pin  <0-31>
-
-
-#ifndef QDEC_CONFIG_PIO_B
-#define QDEC_CONFIG_PIO_B 31
-#endif
-
-// <o> QDEC_CONFIG_PIO_LED - LED pin  <0-31>
-
-
-#ifndef QDEC_CONFIG_PIO_LED
-#define QDEC_CONFIG_PIO_LED 31
-#endif
-
-// <o> QDEC_CONFIG_LEDPRE - LED pre
-#ifndef QDEC_CONFIG_LEDPRE
-#define QDEC_CONFIG_LEDPRE 511
-#endif
-
-// <o> QDEC_CONFIG_LEDPOL  - LED polarity
-
-// <0=> Active low
-// <1=> Active high
-
-#ifndef QDEC_CONFIG_LEDPOL
-#define QDEC_CONFIG_LEDPOL 1
-#endif
-
-// <q> QDEC_CONFIG_DBFEN  - Debouncing enable
-
-
-#ifndef QDEC_CONFIG_DBFEN
-#define QDEC_CONFIG_DBFEN 0
-#endif
-
-// <q> QDEC_CONFIG_SAMPLE_INTEN  - Sample ready interrupt enable
-
-
-#ifndef QDEC_CONFIG_SAMPLE_INTEN
-#define QDEC_CONFIG_SAMPLE_INTEN 0
-#endif
-
-// <o> QDEC_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef QDEC_CONFIG_IRQ_PRIORITY
-#define QDEC_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> QDEC_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef QDEC_CONFIG_LOG_ENABLED
-#define QDEC_CONFIG_LOG_ENABLED 0
-#endif
-#if  QDEC_CONFIG_LOG_ENABLED
-// <o> QDEC_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef QDEC_CONFIG_LOG_LEVEL
-#define QDEC_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> QDEC_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef QDEC_CONFIG_INFO_COLOR
-#define QDEC_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> QDEC_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef QDEC_CONFIG_DEBUG_COLOR
-#define QDEC_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //QDEC_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //QDEC_ENABLED
-// </e>
-
-// <e> RNG_ENABLED - nrf_drv_rng - RNG peripheral driver
-//==========================================================
-#ifndef RNG_ENABLED
-#define RNG_ENABLED 0
-#endif
-#if  RNG_ENABLED
-// <q> RNG_CONFIG_ERROR_CORRECTION  - Error correction
-
-
-#ifndef RNG_CONFIG_ERROR_CORRECTION
-#define RNG_CONFIG_ERROR_CORRECTION 0
-#endif
-
-// <o> RNG_CONFIG_POOL_SIZE - Pool size
-#ifndef RNG_CONFIG_POOL_SIZE
-#define RNG_CONFIG_POOL_SIZE 32
-#endif
-
-// <o> RNG_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef RNG_CONFIG_IRQ_PRIORITY
-#define RNG_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> RNG_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef RNG_CONFIG_LOG_ENABLED
-#define RNG_CONFIG_LOG_ENABLED 0
-#endif
-#if  RNG_CONFIG_LOG_ENABLED
-// <o> RNG_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef RNG_CONFIG_LOG_LEVEL
-#define RNG_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> RNG_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef RNG_CONFIG_INFO_COLOR
-#define RNG_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> RNG_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef RNG_CONFIG_DEBUG_COLOR
-#define RNG_CONFIG_DEBUG_COLOR 0
-#endif
-
-// <q> RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED  - Enables logging of random numbers.
-
-
-#ifndef RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED
-#define RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED 0
-#endif
-
-#endif //RNG_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //RNG_ENABLED
-// </e>
-
-// <e> RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver
-//==========================================================
-#ifndef RTC_ENABLED
-#define RTC_ENABLED 0
-#endif
-#if  RTC_ENABLED
-// <o> RTC_DEFAULT_CONFIG_FREQUENCY - Frequency  <16-32768>
-
-
-#ifndef RTC_DEFAULT_CONFIG_FREQUENCY
-#define RTC_DEFAULT_CONFIG_FREQUENCY 32768
-#endif
-
-// <q> RTC_DEFAULT_CONFIG_RELIABLE  - Ensures safe compare event triggering
-
-
-#ifndef RTC_DEFAULT_CONFIG_RELIABLE
-#define RTC_DEFAULT_CONFIG_RELIABLE 0
-#endif
-
-// <o> RTC_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY
-#define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <q> RTC0_ENABLED  - Enable RTC0 instance
-
-
-#ifndef RTC0_ENABLED
-#define RTC0_ENABLED 0
-#endif
-
-// <q> RTC1_ENABLED  - Enable RTC1 instance
-
-
-#ifndef RTC1_ENABLED
-#define RTC1_ENABLED 0
-#endif
-
-// <q> RTC2_ENABLED  - Enable RTC2 instance
-
-
-#ifndef RTC2_ENABLED
-#define RTC2_ENABLED 0
-#endif
-
-// <o> NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt
-#ifndef NRF_MAXIMUM_LATENCY_US
-#define NRF_MAXIMUM_LATENCY_US 2000
-#endif
-
-// <e> RTC_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef RTC_CONFIG_LOG_ENABLED
-#define RTC_CONFIG_LOG_ENABLED 0
-#endif
-#if  RTC_CONFIG_LOG_ENABLED
-// <o> RTC_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef RTC_CONFIG_LOG_LEVEL
-#define RTC_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> RTC_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef RTC_CONFIG_INFO_COLOR
-#define RTC_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> RTC_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef RTC_CONFIG_DEBUG_COLOR
-#define RTC_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //RTC_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //RTC_ENABLED
-// </e>
-
-// <e> SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver
-//==========================================================
-#ifndef SAADC_ENABLED
-#define SAADC_ENABLED 1
-#endif
-#if  SAADC_ENABLED
-// <o> SAADC_CONFIG_RESOLUTION  - Resolution
-
-// <0=> 8 bit
-// <1=> 10 bit
-// <2=> 12 bit
-// <3=> 14 bit
-
-#ifndef SAADC_CONFIG_RESOLUTION
-#define SAADC_CONFIG_RESOLUTION 2
-#endif
-
-// <o> SAADC_CONFIG_OVERSAMPLE  - Sample period
-
-// <0=> Disabled
-// <1=> 2x
-// <2=> 4x
-// <3=> 8x
-// <4=> 16x
-// <5=> 32x
-// <6=> 64x
-// <7=> 128x
-// <8=> 256x
-
-#ifndef SAADC_CONFIG_OVERSAMPLE
-#define SAADC_CONFIG_OVERSAMPLE 0
-#endif
-
-// <q> SAADC_CONFIG_LP_MODE  - Enabling low power mode
-
-
-#ifndef SAADC_CONFIG_LP_MODE
-#define SAADC_CONFIG_LP_MODE 0
-#endif
-
-// <o> SAADC_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef SAADC_CONFIG_IRQ_PRIORITY
-#define SAADC_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> SAADC_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef SAADC_CONFIG_LOG_ENABLED
-#define SAADC_CONFIG_LOG_ENABLED 0
-#endif
-#if  SAADC_CONFIG_LOG_ENABLED
-// <o> SAADC_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef SAADC_CONFIG_LOG_LEVEL
-#define SAADC_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> SAADC_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef SAADC_CONFIG_INFO_COLOR
-#define SAADC_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> SAADC_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef SAADC_CONFIG_DEBUG_COLOR
-#define SAADC_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //SAADC_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //SAADC_ENABLED
-// </e>
-
-// <e> SPIS_ENABLED - nrf_drv_spis - SPI Slave driver
-//==========================================================
-#ifndef SPIS_ENABLED
-#define SPIS_ENABLED 0
-#endif
-#if  SPIS_ENABLED
-// <o> SPIS_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef SPIS_DEFAULT_CONFIG_IRQ_PRIORITY
-#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <o> SPIS_DEFAULT_MODE  - Mode
-
-// <0=> MODE_0
-// <1=> MODE_1
-// <2=> MODE_2
-// <3=> MODE_3
-
-#ifndef SPIS_DEFAULT_MODE
-#define SPIS_DEFAULT_MODE 0
-#endif
-
-// <o> SPIS_DEFAULT_BIT_ORDER  - SPIS default bit order
-
-// <0=> MSB first
-// <1=> LSB first
-
-#ifndef SPIS_DEFAULT_BIT_ORDER
-#define SPIS_DEFAULT_BIT_ORDER 0
-#endif
-
-// <o> SPIS_DEFAULT_DEF - SPIS default DEF character  <0-255>
-
-
-#ifndef SPIS_DEFAULT_DEF
-#define SPIS_DEFAULT_DEF 255
-#endif
-
-// <o> SPIS_DEFAULT_ORC - SPIS default ORC character  <0-255>
-
-
-#ifndef SPIS_DEFAULT_ORC
-#define SPIS_DEFAULT_ORC 255
-#endif
-
-// <q> SPIS0_ENABLED  - Enable SPIS0 instance
-
-
-#ifndef SPIS0_ENABLED
-#define SPIS0_ENABLED 0
-#endif
-
-// <q> SPIS1_ENABLED  - Enable SPIS1 instance
-
-
-#ifndef SPIS1_ENABLED
-#define SPIS1_ENABLED 0
-#endif
-
-// <q> SPIS2_ENABLED  - Enable SPIS2 instance
-
-
-#ifndef SPIS2_ENABLED
-#define SPIS2_ENABLED 0
-#endif
-
-// <e> SPIS_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef SPIS_CONFIG_LOG_ENABLED
-#define SPIS_CONFIG_LOG_ENABLED 0
-#endif
-#if  SPIS_CONFIG_LOG_ENABLED
-// <o> SPIS_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef SPIS_CONFIG_LOG_LEVEL
-#define SPIS_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> SPIS_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef SPIS_CONFIG_INFO_COLOR
-#define SPIS_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> SPIS_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef SPIS_CONFIG_DEBUG_COLOR
-#define SPIS_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //SPIS_CONFIG_LOG_ENABLED
-// </e>
-
-// <q> SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED  - Enables nRF52 Anomaly 109 workaround for SPIS.
-
-
-// <i> The workaround uses a GPIOTE channel to generate interrupts
-// <i> on falling edges detected on the CSN line. This will make
-// <i> the CPU active for the moment when SPIS starts DMA transfers,
-// <i> and this way the transfers will be protected.
-// <i> This workaround uses GPIOTE driver, so this driver must be
-// <i> enabled as well.
-
-#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED
-#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0
-#endif
-
-#endif //SPIS_ENABLED
-// </e>
-
-// <e> SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver
-//==========================================================
-#ifndef SPI_ENABLED
-#define SPI_ENABLED 0
-#endif
-#if  SPI_ENABLED
-// <o> SPI_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY
-#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> SPI0_ENABLED - Enable SPI0 instance
-//==========================================================
-#ifndef SPI0_ENABLED
-#define SPI0_ENABLED 0
-#endif
-#if  SPI0_ENABLED
-// <q> SPI0_USE_EASY_DMA  - Use EasyDMA
-
-
-#ifndef SPI0_USE_EASY_DMA
-#define SPI0_USE_EASY_DMA 1
-#endif
-
-// <o> SPI0_DEFAULT_FREQUENCY  - SPI frequency
-
-// <33554432=> 125 kHz
-// <67108864=> 250 kHz
-// <134217728=> 500 kHz
-// <268435456=> 1 MHz
-// <536870912=> 2 MHz
-// <1073741824=> 4 MHz
-// <2147483648=> 8 MHz
-
-#ifndef SPI0_DEFAULT_FREQUENCY
-#define SPI0_DEFAULT_FREQUENCY 1073741824
-#endif
-
-#endif //SPI0_ENABLED
-// </e>
-
-// <e> SPI1_ENABLED - Enable SPI1 instance
-//==========================================================
-#ifndef SPI1_ENABLED
-#define SPI1_ENABLED 0
-#endif
-#if  SPI1_ENABLED
-// <q> SPI1_USE_EASY_DMA  - Use EasyDMA
-
-
-#ifndef SPI1_USE_EASY_DMA
-#define SPI1_USE_EASY_DMA 1
-#endif
-
-// <o> SPI1_DEFAULT_FREQUENCY  - SPI frequency
-
-// <33554432=> 125 kHz
-// <67108864=> 250 kHz
-// <134217728=> 500 kHz
-// <268435456=> 1 MHz
-// <536870912=> 2 MHz
-// <1073741824=> 4 MHz
-// <2147483648=> 8 MHz
-
-#ifndef SPI1_DEFAULT_FREQUENCY
-#define SPI1_DEFAULT_FREQUENCY 1073741824
-#endif
-
-#endif //SPI1_ENABLED
-// </e>
-
-// <e> SPI2_ENABLED - Enable SPI2 instance
-//==========================================================
-#ifndef SPI2_ENABLED
-#define SPI2_ENABLED 0
-#endif
-#if  SPI2_ENABLED
-// <q> SPI2_USE_EASY_DMA  - Use EasyDMA
-
-
-#ifndef SPI2_USE_EASY_DMA
-#define SPI2_USE_EASY_DMA 1
-#endif
-
-// <q> SPI2_DEFAULT_FREQUENCY  - Use EasyDMA
-
-
-#ifndef SPI2_DEFAULT_FREQUENCY
-#define SPI2_DEFAULT_FREQUENCY 1
-#endif
-
-#endif //SPI2_ENABLED
-// </e>
-
-// <e> SPI_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef SPI_CONFIG_LOG_ENABLED
-#define SPI_CONFIG_LOG_ENABLED 0
-#endif
-#if  SPI_CONFIG_LOG_ENABLED
-// <o> SPI_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef SPI_CONFIG_LOG_LEVEL
-#define SPI_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> SPI_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef SPI_CONFIG_INFO_COLOR
-#define SPI_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> SPI_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef SPI_CONFIG_DEBUG_COLOR
-#define SPI_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //SPI_CONFIG_LOG_ENABLED
-// </e>
-
-// <q> SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED  - Enables nRF52 anomaly 109 workaround for SPIM.
-
-
-// <i> The workaround uses interrupts to wake up the CPU by catching
-// <i> a start event of zero-length transmission to start the clock. This
-// <i> ensures that the DMA transfer will be executed without issues and
-// <i> that the proper transfer will be started. See more in the Errata
-// <i> document or Anomaly 109 Addendum located at
-// <i> https://infocenter.nordicsemi.com/
-
-#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED
-#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0
-#endif
-
-#endif //SPI_ENABLED
-// </e>
-
-// <e> TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver
-//==========================================================
-#ifndef TIMER_ENABLED
-#define TIMER_ENABLED 0
-#endif
-#if  TIMER_ENABLED
-// <o> TIMER_DEFAULT_CONFIG_FREQUENCY  - Timer frequency if in Timer mode
-
-// <0=> 16 MHz
-// <1=> 8 MHz
-// <2=> 4 MHz
-// <3=> 2 MHz
-// <4=> 1 MHz
-// <5=> 500 kHz
-// <6=> 250 kHz
-// <7=> 125 kHz
-// <8=> 62.5 kHz
-// <9=> 31.25 kHz
-
-#ifndef TIMER_DEFAULT_CONFIG_FREQUENCY
-#define TIMER_DEFAULT_CONFIG_FREQUENCY 0
-#endif
-
-// <o> TIMER_DEFAULT_CONFIG_MODE  - Timer mode or operation
-
-// <0=> Timer
-// <1=> Counter
-
-#ifndef TIMER_DEFAULT_CONFIG_MODE
-#define TIMER_DEFAULT_CONFIG_MODE 0
-#endif
-
-// <o> TIMER_DEFAULT_CONFIG_BIT_WIDTH  - Timer counter bit width
-
-// <0=> 16 bit
-// <1=> 8 bit
-// <2=> 24 bit
-// <3=> 32 bit
-
-#ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH
-#define TIMER_DEFAULT_CONFIG_BIT_WIDTH 0
-#endif
-
-// <o> TIMER_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY
-#define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <q> TIMER0_ENABLED  - Enable TIMER0 instance
-
-
-#ifndef TIMER0_ENABLED
-#define TIMER0_ENABLED 0
-#endif
-
-// <q> TIMER1_ENABLED  - Enable TIMER1 instance
-
-
-#ifndef TIMER1_ENABLED
-#define TIMER1_ENABLED 0
-#endif
-
-// <q> TIMER2_ENABLED  - Enable TIMER2 instance
-
-
-#ifndef TIMER2_ENABLED
-#define TIMER2_ENABLED 0
-#endif
-
-// <q> TIMER3_ENABLED  - Enable TIMER3 instance
-
-
-#ifndef TIMER3_ENABLED
-#define TIMER3_ENABLED 0
-#endif
-
-// <q> TIMER4_ENABLED  - Enable TIMER4 instance
-
-
-#ifndef TIMER4_ENABLED
-#define TIMER4_ENABLED 0
-#endif
-
-// <e> TIMER_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef TIMER_CONFIG_LOG_ENABLED
-#define TIMER_CONFIG_LOG_ENABLED 0
-#endif
-#if  TIMER_CONFIG_LOG_ENABLED
-// <o> TIMER_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef TIMER_CONFIG_LOG_LEVEL
-#define TIMER_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> TIMER_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef TIMER_CONFIG_INFO_COLOR
-#define TIMER_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> TIMER_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef TIMER_CONFIG_DEBUG_COLOR
-#define TIMER_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //TIMER_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //TIMER_ENABLED
-// </e>
-
-// <e> TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver
-//==========================================================
-#ifndef TWIS_ENABLED
-#define TWIS_ENABLED 0
-#endif
-#if  TWIS_ENABLED
-// <o> TWIS_DEFAULT_CONFIG_ADDR0 - Address0
-#ifndef TWIS_DEFAULT_CONFIG_ADDR0
-#define TWIS_DEFAULT_CONFIG_ADDR0 0
-#endif
-
-// <o> TWIS_DEFAULT_CONFIG_ADDR1 - Address1
-#ifndef TWIS_DEFAULT_CONFIG_ADDR1
-#define TWIS_DEFAULT_CONFIG_ADDR1 0
-#endif
-
-// <o> TWIS_DEFAULT_CONFIG_SCL_PULL  - SCL pin pull configuration
-
-// <0=> Disabled
-// <1=> Pull down
-// <3=> Pull up
-
-#ifndef TWIS_DEFAULT_CONFIG_SCL_PULL
-#define TWIS_DEFAULT_CONFIG_SCL_PULL 0
-#endif
-
-// <o> TWIS_DEFAULT_CONFIG_SDA_PULL  - SDA pin pull configuration
-
-// <0=> Disabled
-// <1=> Pull down
-// <3=> Pull up
-
-#ifndef TWIS_DEFAULT_CONFIG_SDA_PULL
-#define TWIS_DEFAULT_CONFIG_SDA_PULL 0
-#endif
-
-// <o> TWIS_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef TWIS_DEFAULT_CONFIG_IRQ_PRIORITY
-#define TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <q> TWIS0_ENABLED  - Enable TWIS0 instance
-
-
-#ifndef TWIS0_ENABLED
-#define TWIS0_ENABLED 0
-#endif
-
-// <q> TWIS1_ENABLED  - Enable TWIS1 instance
-
-
-#ifndef TWIS1_ENABLED
-#define TWIS1_ENABLED 0
-#endif
-
-// <q> TWIS_ASSUME_INIT_AFTER_RESET_ONLY  - Assume that any instance would be initialized only once
-
-
-// <i> Optimization flag. Registers used by TWIS are shared by other peripherals. Normally, during initialization driver tries to clear all registers to known state before doing the initialization itself. This gives initialization safe procedure, no matter when it would be called. If you activate TWIS only once and do never uninitialize it - set this flag to 1 what gives more optimal code.
-
-#ifndef TWIS_ASSUME_INIT_AFTER_RESET_ONLY
-#define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0
-#endif
-
-// <q> TWIS_NO_SYNC_MODE  - Remove support for synchronous mode
-
-
-// <i> Synchronous mode would be used in specific situations. And it uses some additional code and data memory to safely process state machine by polling it in status functions. If this functionality is not required it may be disabled to free some resources.
-
-#ifndef TWIS_NO_SYNC_MODE
-#define TWIS_NO_SYNC_MODE 0
-#endif
-
-// <e> TWIS_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef TWIS_CONFIG_LOG_ENABLED
-#define TWIS_CONFIG_LOG_ENABLED 0
-#endif
-#if  TWIS_CONFIG_LOG_ENABLED
-// <o> TWIS_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef TWIS_CONFIG_LOG_LEVEL
-#define TWIS_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> TWIS_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef TWIS_CONFIG_INFO_COLOR
-#define TWIS_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> TWIS_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef TWIS_CONFIG_DEBUG_COLOR
-#define TWIS_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //TWIS_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //TWIS_ENABLED
-// </e>
-
-// <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver
-//==========================================================
-#ifndef TWI_ENABLED
-#define TWI_ENABLED 0
-#endif
-#if  TWI_ENABLED
-// <o> TWI_DEFAULT_CONFIG_FREQUENCY  - Frequency
-
-// <26738688=> 100k
-// <67108864=> 250k
-// <104857600=> 400k
-
-#ifndef TWI_DEFAULT_CONFIG_FREQUENCY
-#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688
-#endif
-
-// <q> TWI_DEFAULT_CONFIG_CLR_BUS_INIT  - Enables bus clearing procedure during init
-
-
-#ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT
-#define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0
-#endif
-
-// <q> TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT  - Enables bus holding after uninit
-
-
-#ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT
-#define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0
-#endif
-
-// <o> TWI_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY
-#define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> TWI0_ENABLED - Enable TWI0 instance
-//==========================================================
-#ifndef TWI0_ENABLED
-#define TWI0_ENABLED 0
-#endif
-#if  TWI0_ENABLED
-// <q> TWI0_USE_EASY_DMA  - Use EasyDMA (if present)
-
-
-#ifndef TWI0_USE_EASY_DMA
-#define TWI0_USE_EASY_DMA 0
-#endif
-
-#endif //TWI0_ENABLED
-// </e>
-
-// <e> TWI1_ENABLED - Enable TWI1 instance
-//==========================================================
-#ifndef TWI1_ENABLED
-#define TWI1_ENABLED 0
-#endif
-#if  TWI1_ENABLED
-// <q> TWI1_USE_EASY_DMA  - Use EasyDMA (if present)
-
-
-#ifndef TWI1_USE_EASY_DMA
-#define TWI1_USE_EASY_DMA 0
-#endif
-
-#endif //TWI1_ENABLED
-// </e>
-
-// <e> TWI_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef TWI_CONFIG_LOG_ENABLED
-#define TWI_CONFIG_LOG_ENABLED 0
-#endif
-#if  TWI_CONFIG_LOG_ENABLED
-// <o> TWI_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef TWI_CONFIG_LOG_LEVEL
-#define TWI_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> TWI_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef TWI_CONFIG_INFO_COLOR
-#define TWI_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> TWI_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef TWI_CONFIG_DEBUG_COLOR
-#define TWI_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //TWI_CONFIG_LOG_ENABLED
-// </e>
-
-// <q> TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED  - Enables nRF52 anomaly 109 workaround for TWIM.
-
-
-// <i> The workaround uses interrupts to wake up the CPU by catching
-// <i> the start event of zero-frequency transmission, clear the
-// <i> peripheral, set desired frequency, start the peripheral, and
-// <i> the proper transmission. See more in the Errata document or
-// <i> Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/
-
-#ifndef TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED
-#define TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0
-#endif
-
-#endif //TWI_ENABLED
-// </e>
-
-// <e> UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver
-//==========================================================
-#ifndef UART_ENABLED
-#define UART_ENABLED 1
-#endif
-#if  UART_ENABLED
-// <o> UART_DEFAULT_CONFIG_HWFC  - Hardware Flow Control
-
-// <0=> Disabled
-// <1=> Enabled
-
-#ifndef UART_DEFAULT_CONFIG_HWFC
-#define UART_DEFAULT_CONFIG_HWFC 0
-#endif
-
-// <o> UART_DEFAULT_CONFIG_PARITY  - Parity
-
-// <0=> Excluded
-// <14=> Included
-
-#ifndef UART_DEFAULT_CONFIG_PARITY
-#define UART_DEFAULT_CONFIG_PARITY 0
-#endif
-
-// <o> UART_DEFAULT_CONFIG_BAUDRATE  - Default Baudrate
-
-// <323584=> 1200 baud
-// <643072=> 2400 baud
-// <1290240=> 4800 baud
-// <2576384=> 9600 baud
-// <3862528=> 14400 baud
-// <5152768=> 19200 baud
-// <7716864=> 28800 baud
-// <10289152=> 38400 baud
-// <15400960=> 57600 baud
-// <20615168=> 76800 baud
-// <30801920=> 115200 baud
-// <61865984=> 230400 baud
-// <67108864=> 250000 baud
-// <121634816=> 460800 baud
-// <251658240=> 921600 baud
-// <268435456=> 57600 baud
-
-#ifndef UART_DEFAULT_CONFIG_BAUDRATE
-#define UART_DEFAULT_CONFIG_BAUDRATE 30801920
-#endif
-
-// <o> UART_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY
-#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <q> UART_EASY_DMA_SUPPORT  - Driver supporting EasyDMA
-
-
-#ifndef UART_EASY_DMA_SUPPORT
-#define UART_EASY_DMA_SUPPORT 0
-#endif
-
-// <q> UART_LEGACY_SUPPORT  - Driver supporting Legacy mode
-
-
-#ifndef UART_LEGACY_SUPPORT
-#define UART_LEGACY_SUPPORT 1
-#endif
-
-// <e> UART0_ENABLED - Enable UART0 instance
-//==========================================================
-#ifndef UART0_ENABLED
-#define UART0_ENABLED 1
-#endif
-#if  UART0_ENABLED
-// <q> UART0_CONFIG_USE_EASY_DMA  - Default setting for using EasyDMA
-
-
-#ifndef UART0_CONFIG_USE_EASY_DMA
-#define UART0_CONFIG_USE_EASY_DMA 0
-#endif
-
-#endif //UART0_ENABLED
-// </e>
-
-// <e> UART_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef UART_CONFIG_LOG_ENABLED
-#define UART_CONFIG_LOG_ENABLED 0
-#endif
-#if  UART_CONFIG_LOG_ENABLED
-// <o> UART_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef UART_CONFIG_LOG_LEVEL
-#define UART_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> UART_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef UART_CONFIG_INFO_COLOR
-#define UART_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> UART_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef UART_CONFIG_DEBUG_COLOR
-#define UART_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //UART_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //UART_ENABLED
-// </e>
-
-// <e> USBD_ENABLED - nrf_drv_usbd - USB driver
-//==========================================================
-#ifndef USBD_ENABLED
-#define USBD_ENABLED 0
-#endif
-#if  USBD_ENABLED
-// <o> USBD_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef USBD_CONFIG_IRQ_PRIORITY
-#define USBD_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <o> NRF_DRV_USBD_DMASCHEDULER_MODE  - USBD SMA scheduler working scheme
-
-// <0=> Prioritized access
-// <1=> Round Robin
-
-#ifndef NRF_DRV_USBD_DMASCHEDULER_MODE
-#define NRF_DRV_USBD_DMASCHEDULER_MODE 0
-#endif
-
-// <q> NRF_USBD_DRV_LOG_ENABLED  - Enable logging
-
-
-#ifndef NRF_USBD_DRV_LOG_ENABLED
-#define NRF_USBD_DRV_LOG_ENABLED 0
-#endif
-
-#endif //USBD_ENABLED
-// </e>
-
-// <e> WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver
-//==========================================================
-#ifndef WDT_ENABLED
-#define WDT_ENABLED 0
-#endif
-#if  WDT_ENABLED
-// <o> WDT_CONFIG_BEHAVIOUR  - WDT behavior in CPU SLEEP or HALT mode
-
-// <1=> Run in SLEEP, Pause in HALT
-// <8=> Pause in SLEEP, Run in HALT
-// <9=> Run in SLEEP and HALT
-// <0=> Pause in SLEEP and HALT
-
-#ifndef WDT_CONFIG_BEHAVIOUR
-#define WDT_CONFIG_BEHAVIOUR 1
-#endif
-
-// <o> WDT_CONFIG_RELOAD_VALUE - Reload value  <15-4294967295>
-
-
-#ifndef WDT_CONFIG_RELOAD_VALUE
-#define WDT_CONFIG_RELOAD_VALUE 2000
-#endif
-
-// <o> WDT_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef WDT_CONFIG_IRQ_PRIORITY
-#define WDT_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <e> WDT_CONFIG_LOG_ENABLED - Enables logging in the module.
-//==========================================================
-#ifndef WDT_CONFIG_LOG_ENABLED
-#define WDT_CONFIG_LOG_ENABLED 0
-#endif
-#if  WDT_CONFIG_LOG_ENABLED
-// <o> WDT_CONFIG_LOG_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef WDT_CONFIG_LOG_LEVEL
-#define WDT_CONFIG_LOG_LEVEL 3
-#endif
-
-// <o> WDT_CONFIG_INFO_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef WDT_CONFIG_INFO_COLOR
-#define WDT_CONFIG_INFO_COLOR 0
-#endif
-
-// <o> WDT_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef WDT_CONFIG_DEBUG_COLOR
-#define WDT_CONFIG_DEBUG_COLOR 0
-#endif
-
-#endif //WDT_CONFIG_LOG_ENABLED
-// </e>
-
-#endif //WDT_ENABLED
-// </e>
-
-// </h>
-//==========================================================
-
-// <h> nRF_Libraries
-
-//==========================================================
-// <q> APP_FIFO_ENABLED  - app_fifo - Software FIFO implementation
-
-
-#ifndef APP_FIFO_ENABLED
-#define APP_FIFO_ENABLED 1
-#endif
-
-// <q> APP_GPIOTE_ENABLED  - app_gpiote - GPIOTE events dispatcher
-
-
-#ifndef APP_GPIOTE_ENABLED
-#define APP_GPIOTE_ENABLED 0
-#endif
-
-// <q> APP_PWM_ENABLED  - app_pwm - PWM functionality
-
-
-#ifndef APP_PWM_ENABLED
-#define APP_PWM_ENABLED 0
-#endif
-
-// <e> APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler
-//==========================================================
-#ifndef APP_SCHEDULER_ENABLED
-#define APP_SCHEDULER_ENABLED 1
-#endif
-#if  APP_SCHEDULER_ENABLED
-// <q> APP_SCHEDULER_WITH_PAUSE  - Enabling pause feature
-
-
-#ifndef APP_SCHEDULER_WITH_PAUSE
-#define APP_SCHEDULER_WITH_PAUSE 0
-#endif
-
-// <q> APP_SCHEDULER_WITH_PROFILER  - Enabling scheduler profiling
-
-
-#ifndef APP_SCHEDULER_WITH_PROFILER
-#define APP_SCHEDULER_WITH_PROFILER 0
-#endif
-
-#endif //APP_SCHEDULER_ENABLED
-// </e>
-
-// <e> APP_TIMER_ENABLED - app_timer - Application timer functionality
-//==========================================================
-#ifndef APP_TIMER_ENABLED
-#define APP_TIMER_ENABLED 1
-#endif
-#if  APP_TIMER_ENABLED
-// <o> APP_TIMER_CONFIG_RTC_FREQUENCY  - Configure RTC prescaler.
-
-// <0=> 32768 Hz
-// <1=> 16384 Hz
-// <3=> 8192 Hz
-// <7=> 4096 Hz
-// <15=> 2048 Hz
-// <31=> 1024 Hz
-
-#ifndef APP_TIMER_CONFIG_RTC_FREQUENCY
-#define APP_TIMER_CONFIG_RTC_FREQUENCY 0
-#endif
-
-// <o> APP_TIMER_CONFIG_IRQ_PRIORITY  - Interrupt priority
-
-
-// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
-// <0=> 0 (highest)
-// <1=> 1
-// <2=> 2
-// <3=> 3
-// <4=> 4
-// <5=> 5
-// <6=> 6
-// <7=> 7
-
-#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY
-#define APP_TIMER_CONFIG_IRQ_PRIORITY 7
-#endif
-
-// <o> APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue.
-// <i> Size of the queue depends on how many timers are used
-// <i> in the system, how often timers are started and overall
-// <i> system latency. If queue size is too small app_timer calls
-// <i> will fail.
-
-#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE
-#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10
-#endif
-
-// <q> APP_TIMER_CONFIG_USE_SCHEDULER  - Enable scheduling app_timer events to app_scheduler
-
-
-#ifndef APP_TIMER_CONFIG_USE_SCHEDULER
-#define APP_TIMER_CONFIG_USE_SCHEDULER 0
-#endif
-
-// <q> APP_TIMER_WITH_PROFILER  - Enable app_timer profiling
-
-
-#ifndef APP_TIMER_WITH_PROFILER
-#define APP_TIMER_WITH_PROFILER 0
-#endif
-
-// <q> APP_TIMER_KEEPS_RTC_ACTIVE  - Enable RTC always on
-
-
-// <i> If option is enabled RTC is kept running even if there is no active timers.
-// <i> This option can be used when app_timer is used for timestamping.
-
-#ifndef APP_TIMER_KEEPS_RTC_ACTIVE
-#define APP_TIMER_KEEPS_RTC_ACTIVE 0
-#endif
-
-// <o> APP_TIMER_CONFIG_SWI_NUMBER  - Configure SWI instance used.
-
-// <0=> 0
-// <1=> 1
-
-#ifndef APP_TIMER_CONFIG_SWI_NUMBER
-#define APP_TIMER_CONFIG_SWI_NUMBER 0
-#endif
-
-#endif //APP_TIMER_ENABLED
-// </e>
-
-// <q> APP_TWI_ENABLED  - app_twi - TWI transaction manager
-
-
-#ifndef APP_TWI_ENABLED
-#define APP_TWI_ENABLED 0
-#endif
-
-// <e> APP_UART_ENABLED - app_uart - UART driver
-//==========================================================
-#ifndef APP_UART_ENABLED
-#define APP_UART_ENABLED 1
-#endif
-#if  APP_UART_ENABLED
-// <o> APP_UART_DRIVER_INSTANCE  - UART instance used
-
-// <0=> 0
-
-#ifndef APP_UART_DRIVER_INSTANCE
-#define APP_UART_DRIVER_INSTANCE 0
-#endif
-
-#endif //APP_UART_ENABLED
-// </e>
-
-// <q> APP_USBD_CLASS_AUDIO_ENABLED  - app_usbd_audio - USB AUDIO class
-
-
-#ifndef APP_USBD_CLASS_AUDIO_ENABLED
-#define APP_USBD_CLASS_AUDIO_ENABLED 0
-#endif
-
-// <q> APP_USBD_CLASS_HID_ENABLED  - app_usbd_hid - USB HID class
-
-
-#ifndef APP_USBD_CLASS_HID_ENABLED
-#define APP_USBD_CLASS_HID_ENABLED 0
-#endif
-
-// <q> APP_USBD_HID_GENERIC_ENABLED  - app_usbd_hid_generic - USB HID generic
-
-
-#ifndef APP_USBD_HID_GENERIC_ENABLED
-#define APP_USBD_HID_GENERIC_ENABLED 0
-#endif
-
-// <q> APP_USBD_HID_KBD_ENABLED  - app_usbd_hid_kbd - USB HID keyboard
-
-
-#ifndef APP_USBD_HID_KBD_ENABLED
-#define APP_USBD_HID_KBD_ENABLED 0
-#endif
-
-// <q> APP_USBD_HID_MOUSE_ENABLED  - app_usbd_hid_mouse - USB HID mouse
-
-
-#ifndef APP_USBD_HID_MOUSE_ENABLED
-#define APP_USBD_HID_MOUSE_ENABLED 0
-#endif
-
-// <q> BUTTON_ENABLED  - app_button - buttons handling module
-
-
-#ifndef BUTTON_ENABLED
-#define BUTTON_ENABLED 1
-#endif
-
-// <q> CRC16_ENABLED  - crc16 - CRC16 calculation routines
-
-
-#ifndef CRC16_ENABLED
-#define CRC16_ENABLED 0
-#endif
-
-// <q> CRC32_ENABLED  - crc32 - CRC32 calculation routines
-
-
-#ifndef CRC32_ENABLED
-#define CRC32_ENABLED 0
-#endif
-
-// <q> ECC_ENABLED  - ecc - Elliptic Curve Cryptography Library
-
-
-#ifndef ECC_ENABLED
-#define ECC_ENABLED 0
-#endif
-
-// <e> FDS_ENABLED - fds - Flash data storage module
-//==========================================================
-#ifndef FDS_ENABLED
-#define FDS_ENABLED 0
-#endif
-#if  FDS_ENABLED
-// <o> FDS_OP_QUEUE_SIZE - Size of the internal queue.
-#ifndef FDS_OP_QUEUE_SIZE
-#define FDS_OP_QUEUE_SIZE 4
-#endif
-
-// <o> FDS_CHUNK_QUEUE_SIZE - Determines how many @ref fds_record_chunk_t structures can be buffered at any time.
-#ifndef FDS_CHUNK_QUEUE_SIZE
-#define FDS_CHUNK_QUEUE_SIZE 8
-#endif
-
-// <o> FDS_MAX_USERS - Maximum number of callbacks that can be registered.
-#ifndef FDS_MAX_USERS
-#define FDS_MAX_USERS 8
-#endif
-
-// <o> FDS_VIRTUAL_PAGES - Number of virtual flash pages to use.
-// <i> One of the virtual pages is reserved by the system for garbage collection.
-// <i> Therefore, the minimum is two virtual pages: one page to store data and
-// <i> one page to be used by the system for garbage collection. The total amount
-// <i> of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES
-// <i> @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes.
-
-#ifndef FDS_VIRTUAL_PAGES
-#define FDS_VIRTUAL_PAGES 3
-#endif
-
-// <o> FDS_VIRTUAL_PAGE_SIZE  - The size of a virtual page of flash memory, expressed in number of 4-byte words.
-
-
-// <i> By default, a virtual page is the same size as a physical page.
-// <i> The size of a virtual page must be a multiple of the size of a physical page.
-// <1024=> 1024
-// <2048=> 2048
-
-#ifndef FDS_VIRTUAL_PAGE_SIZE
-#define FDS_VIRTUAL_PAGE_SIZE 1024
-#endif
-
-#endif //FDS_ENABLED
-// </e>
-
-// <e> FSTORAGE_ENABLED - fstorage - Flash storage module
-//==========================================================
-#ifndef FSTORAGE_ENABLED
-#define FSTORAGE_ENABLED 1
-#endif
-#if  FSTORAGE_ENABLED
-// <o> FS_QUEUE_SIZE - Configures the size of the internal queue.
-// <i> Increase this if there are many users, or if it is likely that many
-// <i> operation will be queued at once without waiting for the previous operations
-// <i> to complete. In general, increase the queue size if you frequently receive
-// <i> @ref FS_ERR_QUEUE_FULL errors when calling @ref fs_store or @ref fs_erase.
-
-#ifndef FS_QUEUE_SIZE
-#define FS_QUEUE_SIZE 4
-#endif
-
-// <o> FS_OP_MAX_RETRIES - Number attempts to execute an operation if the SoftDevice fails.
-// <i> Increase this value if events return the @ref FS_ERR_OPERATION_TIMEOUT
-// <i> error often. The SoftDevice may fail to schedule flash access due to high BLE activity.
-
-#ifndef FS_OP_MAX_RETRIES
-#define FS_OP_MAX_RETRIES 3
-#endif
-
-// <o> FS_MAX_WRITE_SIZE_WORDS - Maximum number of words to be written to flash in a single operation.
-// <i> Tweaking this value can increase the chances of the SoftDevice being
-// <i> able to fit flash operations in between radio activity. This value is bound by the
-// <i> maximum number of words which the SoftDevice can write to flash in a single call to
-// <i> @ref sd_flash_write, which is 256 words for nRF51 ICs and 1024 words for nRF52 ICs.
-
-#ifndef FS_MAX_WRITE_SIZE_WORDS
-#define FS_MAX_WRITE_SIZE_WORDS 1024
-#endif
-
-#endif //FSTORAGE_ENABLED
-// </e>
-
-// <q> HARDFAULT_HANDLER_ENABLED  - hardfault_default - HardFault default handler for debugging and release
-
-
-#ifndef HARDFAULT_HANDLER_ENABLED
-#define HARDFAULT_HANDLER_ENABLED 0
-#endif
-
-// <e> HCI_MEM_POOL_ENABLED - hci_mem_pool - memory pool implementation used by HCI
-//==========================================================
-#ifndef HCI_MEM_POOL_ENABLED
-#define HCI_MEM_POOL_ENABLED 0
-#endif
-#if  HCI_MEM_POOL_ENABLED
-// <o> HCI_TX_BUF_SIZE - TX buffer size in bytes.
-#ifndef HCI_TX_BUF_SIZE
-#define HCI_TX_BUF_SIZE 600
-#endif
-
-// <o> HCI_RX_BUF_SIZE - RX buffer size in bytes.
-#ifndef HCI_RX_BUF_SIZE
-#define HCI_RX_BUF_SIZE 600
-#endif
-
-// <o> HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size.
-#ifndef HCI_RX_BUF_QUEUE_SIZE
-#define HCI_RX_BUF_QUEUE_SIZE 4
-#endif
-
-#endif //HCI_MEM_POOL_ENABLED
-// </e>
-
-// <e> HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI
-//==========================================================
-#ifndef HCI_SLIP_ENABLED
-#define HCI_SLIP_ENABLED 0
-#endif
-#if  HCI_SLIP_ENABLED
-// <o> HCI_UART_BAUDRATE  - Default Baudrate
-
-// <323584=> 1200 baud
-// <643072=> 2400 baud
-// <1290240=> 4800 baud
-// <2576384=> 9600 baud
-// <3862528=> 14400 baud
-// <5152768=> 19200 baud
-// <7716864=> 28800 baud
-// <10289152=> 38400 baud
-// <15400960=> 57600 baud
-// <20615168=> 76800 baud
-// <30801920=> 115200 baud
-// <61865984=> 230400 baud
-// <67108864=> 250000 baud
-// <121634816=> 460800 baud
-// <251658240=> 921600 baud
-// <268435456=> 57600 baud
-
-#ifndef HCI_UART_BAUDRATE
-#define HCI_UART_BAUDRATE 30801920
-#endif
-
-// <o> HCI_UART_FLOW_CONTROL  - Hardware Flow Control
-
-// <0=> Disabled
-// <1=> Enabled
-
-#ifndef HCI_UART_FLOW_CONTROL
-#define HCI_UART_FLOW_CONTROL 0
-#endif
-
-// <o> HCI_UART_RX_PIN - UART RX pin
-#ifndef HCI_UART_RX_PIN
-#define HCI_UART_RX_PIN 8
-#endif
-
-// <o> HCI_UART_TX_PIN - UART TX pin
-#ifndef HCI_UART_TX_PIN
-#define HCI_UART_TX_PIN 6
-#endif
-
-// <o> HCI_UART_RTS_PIN - UART RTS pin
-#ifndef HCI_UART_RTS_PIN
-#define HCI_UART_RTS_PIN 5
-#endif
-
-// <o> HCI_UART_CTS_PIN - UART CTS pin
-#ifndef HCI_UART_CTS_PIN
-#define HCI_UART_CTS_PIN 7
-#endif
-
-#endif //HCI_SLIP_ENABLED
-// </e>
-
-// <e> HCI_TRANSPORT_ENABLED - hci_transport - HCI transport
-//==========================================================
-#ifndef HCI_TRANSPORT_ENABLED
-#define HCI_TRANSPORT_ENABLED 0
-#endif
-#if  HCI_TRANSPORT_ENABLED
-// <o> HCI_MAX_PACKET_SIZE_IN_BITS - Maximum size of a single application packet in bits.
-#ifndef HCI_MAX_PACKET_SIZE_IN_BITS
-#define HCI_MAX_PACKET_SIZE_IN_BITS 8000
-#endif
-
-#endif //HCI_TRANSPORT_ENABLED
-// </e>
-
-// <q> LED_SOFTBLINK_ENABLED  - led_softblink - led_softblink module
-
-
-#ifndef LED_SOFTBLINK_ENABLED
-#define LED_SOFTBLINK_ENABLED 0
-#endif
-
-// <q> LOW_POWER_PWM_ENABLED  - low_power_pwm - low_power_pwm module
-
-
-#ifndef LOW_POWER_PWM_ENABLED
-#define LOW_POWER_PWM_ENABLED 0
-#endif
-
-// <e> MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator
-//==========================================================
-#ifndef MEM_MANAGER_ENABLED
-#define MEM_MANAGER_ENABLED 0
-#endif
-#if  MEM_MANAGER_ENABLED
-// <o> MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block.  <0-255>
-
-
-#ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT
-#define MEMORY_MANAGER_SMALL_BLOCK_COUNT 1
-#endif
-
-// <o> MEMORY_MANAGER_SMALL_BLOCK_SIZE -  Size of each memory blocks identified as 'small' block.
-// <i>  Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized.
-
-#ifndef MEMORY_MANAGER_SMALL_BLOCK_SIZE
-#define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32
-#endif
-
-// <o> MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block.  <0-255>
-
-
-#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_COUNT
-#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 0
-#endif
-
-// <o> MEMORY_MANAGER_MEDIUM_BLOCK_SIZE -  Size of each memory blocks identified as 'medium' block.
-// <i>  Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized.
-
-#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_SIZE
-#define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256
-#endif
-
-// <o> MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block.  <0-255>
-
-
-#ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT
-#define MEMORY_MANAGER_LARGE_BLOCK_COUNT 0
-#endif
-
-// <o> MEMORY_MANAGER_LARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'large' block.
-// <i>  Size of each memory blocks identified as 'large' block. Memory block are recommended to be word-sized.
-
-#ifndef MEMORY_MANAGER_LARGE_BLOCK_SIZE
-#define MEMORY_MANAGER_LARGE_BLOCK_SIZE 256
-#endif
-
-// <o> MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block.  <0-255>
-
-
-#ifndef MEMORY_MANAGER_XLARGE_BLOCK_COUNT
-#define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 0
-#endif
-
-// <o> MEMORY_MANAGER_XLARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'extra large' block.
-// <i>  Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized.
-
-#ifndef MEMORY_MANAGER_XLARGE_BLOCK_SIZE
-#define MEMORY_MANAGER_XLARGE_BLOCK_SIZE 1320
-#endif
-
-// <o> MEMORY_MANAGER_XXLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra large' block.  <0-255>
-
-
-#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_COUNT
-#define MEMORY_MANAGER_XXLARGE_BLOCK_COUNT 0
-#endif
-
-// <o> MEMORY_MANAGER_XXLARGE_BLOCK_SIZE -  Size of each memory blocks identified as 'extra extra large' block.
-// <i>  Size of each memory blocks identified as 'extra extra large' block. Memory block are recommended to be word-sized.
-
-#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_SIZE
-#define MEMORY_MANAGER_XXLARGE_BLOCK_SIZE 3444
-#endif
-
-// <o> MEMORY_MANAGER_XSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra small' block.  <0-255>
-
-
-#ifndef MEMORY_MANAGER_XSMALL_BLOCK_COUNT
-#define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 0
-#endif
-
-// <o> MEMORY_MANAGER_XSMALL_BLOCK_SIZE -  Size of each memory blocks identified as 'extra small' block.
-// <i>  Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized.
-
-#ifndef MEMORY_MANAGER_XSMALL_BLOCK_SIZE
-#define MEMORY_MANAGER_XSMALL_BLOCK_SIZE 64
-#endif
-
-// <o> MEMORY_MANAGER_XXSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra small' block.  <0-255>
-
-
-#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_COUNT
-#define MEMORY_MANAGER_XXSMALL_BLOCK_COUNT 0
-#endif
-
-// <o> MEMORY_MANAGER_XXSMALL_BLOCK_SIZE -  Size of each memory blocks identified as 'extra extra small' block.
-// <i>  Size of each memory blocks identified as 'extra extra small' block. Memory block are recommended to be word-sized.
-
-#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_SIZE
-#define MEMORY_MANAGER_XXSMALL_BLOCK_SIZE 32
-#endif
-
-// <q> MEM_MANAGER_ENABLE_LOGS  - Enable debug trace in the module.
-
-
-#ifndef MEM_MANAGER_ENABLE_LOGS
-#define MEM_MANAGER_ENABLE_LOGS 0
-#endif
-
-// <q> MEM_MANAGER_DISABLE_API_PARAM_CHECK  - Disable API parameter checks in the module.
-
-
-#ifndef MEM_MANAGER_DISABLE_API_PARAM_CHECK
-#define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0
-#endif
-
-#endif //MEM_MANAGER_ENABLED
-// </e>
-
-// <e> NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module
-//==========================================================
-#ifndef NRF_CSENSE_ENABLED
-#define NRF_CSENSE_ENABLED 0
-#endif
-#if  NRF_CSENSE_ENABLED
-// <o> NRF_CSENSE_PAD_HYSTERESIS - Minimum value of change required to determine that a pad was touched.
-#ifndef NRF_CSENSE_PAD_HYSTERESIS
-#define NRF_CSENSE_PAD_HYSTERESIS 15
-#endif
-
-// <o> NRF_CSENSE_PAD_DEVIATION - Minimum value measured on a pad required to take it into account while calculating the step.
-#ifndef NRF_CSENSE_PAD_DEVIATION
-#define NRF_CSENSE_PAD_DEVIATION 70
-#endif
-
-// <o> NRF_CSENSE_MIN_PAD_VALUE - Minimum normalized value on a pad required to take its value into account.
-#ifndef NRF_CSENSE_MIN_PAD_VALUE
-#define NRF_CSENSE_MIN_PAD_VALUE 20
-#endif
-
-// <o> NRF_CSENSE_MAX_PADS_NUMBER - Maximum number of pads used for one instance.
-#ifndef NRF_CSENSE_MAX_PADS_NUMBER
-#define NRF_CSENSE_MAX_PADS_NUMBER 20
-#endif
-
-// <o> NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement.
-#ifndef NRF_CSENSE_MAX_VALUE
-#define NRF_CSENSE_MAX_VALUE 1000
-#endif
-
-// <o> NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module.
-// <i> This is used when capacitive sensor does not use COMP.
-
-#ifndef NRF_CSENSE_OUTPUT_PIN
-#define NRF_CSENSE_OUTPUT_PIN 26
-#endif
-
-#endif //NRF_CSENSE_ENABLED
-// </e>
-
-// <e> NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module
-//==========================================================
-#ifndef NRF_DRV_CSENSE_ENABLED
-#define NRF_DRV_CSENSE_ENABLED 0
-#endif
-#if  NRF_DRV_CSENSE_ENABLED
-// <e> USE_COMP - Use the comparator to implement the capacitive sensor driver.
-
-// <i> Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation.
-//==========================================================
-#ifndef USE_COMP
-#define USE_COMP 0
-#endif
-#if  USE_COMP
-// <o> TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51).
-#ifndef TIMER0_FOR_CSENSE
-#define TIMER0_FOR_CSENSE 1
-#endif
-
-// <o> TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51).
-#ifndef TIMER1_FOR_CSENSE
-#define TIMER1_FOR_CSENSE 2
-#endif
-
-// <o> MEASUREMENT_PERIOD - Single measurement period.
-// <i> Time of a single measurement can be calculated as
-// <i> T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ).
-// <i> I_SOURCE, VUP, and VDOWN are values used to initialize COMP and C is the capacitance of the used pad.
-
-#ifndef MEASUREMENT_PERIOD
-#define MEASUREMENT_PERIOD 20
-#endif
-
-#endif //USE_COMP
-// </e>
-
-#endif //NRF_DRV_CSENSE_ENABLED
-// </e>
-
-// <q> NRF_QUEUE_ENABLED  - nrf_queue - Queue module
-
-
-#ifndef NRF_QUEUE_ENABLED
-#define NRF_QUEUE_ENABLED 0
-#endif
-
-// <q> NRF_STRERROR_ENABLED  - nrf_strerror - Library for converting error code to string.
-
-
-#ifndef NRF_STRERROR_ENABLED
-#define NRF_STRERROR_ENABLED 1
-#endif
-
-// <q> RETARGET_ENABLED  - retarget - Retargeting stdio functions
-
-
-#ifndef RETARGET_ENABLED
-#define RETARGET_ENABLED 1
-#endif
-
-// <q> SLIP_ENABLED  - slip - SLIP encoding and decoding
-
-
-#ifndef SLIP_ENABLED
-#define SLIP_ENABLED 0
-#endif
-
-// <h> app_usbd_cdc_acm - USB CDC ACM class
-
-//==========================================================
-// <q> APP_USBD_CLASS_CDC_ACM_ENABLED  - Enabling USBD CDC ACM Class library
-
-
-#ifndef APP_USBD_CLASS_CDC_ACM_ENABLED
-#define APP_USBD_CLASS_CDC_ACM_ENABLED 0
-#endif
-
-// <q> APP_USBD_CDC_ACM_LOG_ENABLED  - Enables logging in the module.
-
-
-#ifndef APP_USBD_CDC_ACM_LOG_ENABLED
-#define APP_USBD_CDC_ACM_LOG_ENABLED 0
-#endif
-
-// </h>
-//==========================================================
-
-// <h> app_usbd_msc - USB MSC class
-
-//==========================================================
-// <q> APP_USBD_CLASS_MSC_ENABLED  - Enabling USBD MSC Class library
-
-
-#ifndef APP_USBD_CLASS_MSC_ENABLED
-#define APP_USBD_CLASS_MSC_ENABLED 0
-#endif
-
-// <q> APP_USBD_MSC_CLASS_LOG_ENABLED  - Enables logging in the module.
-
-
-#ifndef APP_USBD_MSC_CLASS_LOG_ENABLED
-#define APP_USBD_MSC_CLASS_LOG_ENABLED 0
-#endif
-
-// </h>
-//==========================================================
-
-// </h>
-//==========================================================
-
-// <h> nRF_Log
-
-//==========================================================
-// <e> NRF_LOG_ENABLED - nrf_log - Logging
-//==========================================================
-#ifndef NRF_LOG_ENABLED
-#define NRF_LOG_ENABLED 0
-#endif
-#if  NRF_LOG_ENABLED
-// <e> NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string
-//==========================================================
-#ifndef NRF_LOG_USES_COLORS
-#define NRF_LOG_USES_COLORS 0
-#endif
-#if  NRF_LOG_USES_COLORS
-// <o> NRF_LOG_COLOR_DEFAULT  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef NRF_LOG_COLOR_DEFAULT
-#define NRF_LOG_COLOR_DEFAULT 0
-#endif
-
-// <o> NRF_LOG_ERROR_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef NRF_LOG_ERROR_COLOR
-#define NRF_LOG_ERROR_COLOR 0
-#endif
-
-// <o> NRF_LOG_WARNING_COLOR  - ANSI escape code prefix.
-
-// <0=> Default
-// <1=> Black
-// <2=> Red
-// <3=> Green
-// <4=> Yellow
-// <5=> Blue
-// <6=> Magenta
-// <7=> Cyan
-// <8=> White
-
-#ifndef NRF_LOG_WARNING_COLOR
-#define NRF_LOG_WARNING_COLOR 0
-#endif
-
-#endif //NRF_LOG_USES_COLORS
-// </e>
-
-// <o> NRF_LOG_DEFAULT_LEVEL  - Default Severity level
-
-// <0=> Off
-// <1=> Error
-// <2=> Warning
-// <3=> Info
-// <4=> Debug
-
-#ifndef NRF_LOG_DEFAULT_LEVEL
-#define NRF_LOG_DEFAULT_LEVEL 3
-#endif
-
-// <e> NRF_LOG_DEFERRED - Enable deffered logger.
-
-// <i> Log data is buffered and can be processed in idle.
-//==========================================================
-#ifndef NRF_LOG_DEFERRED
-#define NRF_LOG_DEFERRED 0
-#endif
-#if  NRF_LOG_DEFERRED
-// <o> NRF_LOG_DEFERRED_BUFSIZE - Size of the buffer for logs in words.
-// <i> Must be power of 2
-
-#ifndef NRF_LOG_DEFERRED_BUFSIZE
-#define NRF_LOG_DEFERRED_BUFSIZE 256
-#endif
-
-#endif //NRF_LOG_DEFERRED
-// </e>
-
-// <q> NRF_LOG_USES_TIMESTAMP  - Enable timestamping
-
-
-// <i> Function for getting the timestamp is provided by the user
-
-#ifndef NRF_LOG_USES_TIMESTAMP
-#define NRF_LOG_USES_TIMESTAMP 0
-#endif
-
-#endif //NRF_LOG_ENABLED
-// </e>
-
-// <h> nrf_log_backend - Logging sink
-
-//==========================================================
-// <o> NRF_LOG_BACKEND_MAX_STRING_LENGTH - Buffer for storing single output string
-// <i> Logger backend RAM usage is determined by this value.
-
-#ifndef NRF_LOG_BACKEND_MAX_STRING_LENGTH
-#define NRF_LOG_BACKEND_MAX_STRING_LENGTH 256
-#endif
-
-// <o> NRF_LOG_TIMESTAMP_DIGITS - Number of digits for timestamp
-// <i> If higher resolution timestamp source is used it might be needed to increase that
-
-#ifndef NRF_LOG_TIMESTAMP_DIGITS
-#define NRF_LOG_TIMESTAMP_DIGITS 8
-#endif
-
-// <e> NRF_LOG_BACKEND_SERIAL_USES_UART - If enabled data is printed over UART
-//==========================================================
-#ifndef NRF_LOG_BACKEND_SERIAL_USES_UART
-#define NRF_LOG_BACKEND_SERIAL_USES_UART 0
-#endif
-#if  NRF_LOG_BACKEND_SERIAL_USES_UART
-// <o> NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE  - Default Baudrate
-
-// <323584=> 1200 baud
-// <643072=> 2400 baud
-// <1290240=> 4800 baud
-// <2576384=> 9600 baud
-// <3862528=> 14400 baud
-// <5152768=> 19200 baud
-// <7716864=> 28800 baud
-// <10289152=> 38400 baud
-// <15400960=> 57600 baud
-// <20615168=> 76800 baud
-// <30801920=> 115200 baud
-// <61865984=> 230400 baud
-// <67108864=> 250000 baud
-// <121634816=> 460800 baud
-// <251658240=> 921600 baud
-// <268435456=> 57600 baud
-
-#ifndef NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE
-#define NRF_LOG_BACKEND_SERIAL_UART_BAUDRATE 30801920
-#endif
-
-// <o> NRF_LOG_BACKEND_SERIAL_UART_TX_PIN - UART TX pin
-#ifndef NRF_LOG_BACKEND_SERIAL_UART_TX_PIN
-#define NRF_LOG_BACKEND_SERIAL_UART_TX_PIN 4
-#endif
-
-// <o> NRF_LOG_BACKEND_SERIAL_UART_RX_PIN - UART RX pin
-#ifndef NRF_LOG_BACKEND_SERIAL_UART_RX_PIN
-#define NRF_LOG_BACKEND_SERIAL_UART_RX_PIN 3
-#endif
-
-// <o> NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN - UART RTS pin
-#ifndef NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN
-#define NRF_LOG_BACKEND_SERIAL_UART_RTS_PIN 5
-#endif
-
-// <o> NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN - UART CTS pin
-#ifndef NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN
-#define NRF_LOG_BACKEND_SERIAL_UART_CTS_PIN 7
-#endif
-
-// <o> NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL  - Hardware Flow Control
-
-// <0=> Disabled
-// <1=> Enabled
-
-#ifndef NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL
-#define NRF_LOG_BACKEND_SERIAL_UART_FLOW_CONTROL 0
-#endif
-
-// <o> NRF_LOG_BACKEND_UART_INSTANCE  - UART instance used
-
-// <0=> 0
-
-#ifndef NRF_LOG_BACKEND_UART_INSTANCE
-#define NRF_LOG_BACKEND_UART_INSTANCE 0
-#endif
-
-#endif //NRF_LOG_BACKEND_SERIAL_USES_UART
-// </e>
-
-// <e> NRF_LOG_BACKEND_SERIAL_USES_RTT - If enabled data is printed using RTT
-//==========================================================
-#ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT
-#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0
-#endif
-#if  NRF_LOG_BACKEND_SERIAL_USES_RTT
-// <o> NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE - RTT output buffer size.
-// <i> Should be equal or bigger than \ref NRF_LOG_BACKEND_MAX_STRING_LENGTH.
-// <i> This value is used in Segger RTT configuration to set the buffer size
-// <i> if it is bigger than default RTT buffer size.
-
-#ifndef NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE
-#define NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE 512
-#endif
-
-#endif //NRF_LOG_BACKEND_SERIAL_USES_RTT
-// </e>
-
-// </h>
-//==========================================================
-
-// </h>
-//==========================================================
-
-// <h> nRF_Segger_RTT
-
-//==========================================================
-// <h> segger_rtt - SEGGER RTT
-
-//==========================================================
-// <o> SEGGER_RTT_CONFIG_BUFFER_SIZE_UP - Size of upstream buffer.
-// <i> Note that either @ref NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE
-// <i> or this value is actually used. It depends on which one is bigger.
-
-#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_UP
-#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 64
-#endif
-
-// <o> SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer.
-#ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS
-#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2
-#endif
-
-// <o> SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer.
-#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN
-#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16
-#endif
-
-// <o> SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer.
-#ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS
-#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2
-#endif
-
-// <o> SEGGER_RTT_CONFIG_DEFAULT_MODE  - RTT behavior if the buffer is full.
-
-
-// <i> The following modes are supported:
-// <i> - SKIP  - Do not block, output nothing.
-// <i> - TRIM  - Do not block, output as much as fits.
-// <i> - BLOCK - Wait until there is space in the buffer.
-// <0=> SKIP
-// <1=> TRIM
-// <2=> BLOCK_IF_FIFO_FULL
-
-#ifndef SEGGER_RTT_CONFIG_DEFAULT_MODE
-#define SEGGER_RTT_CONFIG_DEFAULT_MODE 0
-#endif
-
-// </h>
-//==========================================================
-
-// </h>
-//==========================================================
-
-// <<< end of configuration section >>>
-#endif //SDK_CONFIG_H
-

+ 0 - 98
bsp/nrf52832/applications/startup.c

@@ -1,98 +0,0 @@
-/*
- * File      : startup.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2015, RT-Thread Develop Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://openlab.rt-thread.com/license/LICENSE
- *
- * Change Logs:
- * Date           Author       Notes
- * 2015-03-01     Yangfs       the first version
- * 2015-03-27     Bernard      code cleanup.
- */
-
-#include <rthw.h>
-#include <rtthread.h>
-
-#include "board.h"
-
-/**
- * @addtogroup NRF52832
- */
-
-/*@{*/
-
-extern int  rt_application_init(void);
-
-#ifdef __CC_ARM
-extern int Image$$RW_IRAM1$$ZI$$Limit;
-#define NRF_SRAM_BEGIN    (&Image$$RW_IRAM1$$ZI$$Limit)
-#elif __ICCARM__
-#pragma section="HEAP"
-#define NRF_SRAM_BEGIN    (__segment_end("HEAP"))
-#else
-extern int __bss_end;
-#define NRF_SRAM_BEGIN    (&__bss_end)
-#endif
-
-/**
- * This function will startup RT-Thread RTOS.
- */
-void rtthread_startup(void)
-{
-    /* init board */
-    rt_hw_board_init();
-
-    /* show version */
-    rt_show_version();
-
-    /* init tick */
-    rt_system_tick_init();
-
-    /* init kernel object */
-    rt_system_object_init();
-
-    /* init timer system */
-    rt_system_timer_init();
-
-#ifdef RT_USING_HEAP
-    rt_system_heap_init((void*)NRF_SRAM_BEGIN, (void*)CHIP_SRAM_END);
-#endif
-
-    /* init scheduler system */
-    rt_system_scheduler_init();
-
-#ifdef RT_USING_COMPONENTS_INIT
-    rt_components_init();
-#endif
-
-    /* init application */
-    rt_application_init();
-
-    /* init timer thread */
-    rt_system_timer_thread_init();
-
-    /* init idle thread */
-    rt_thread_idle_init();
-
-    /* start scheduler */
-    rt_system_scheduler_start();
-
-    /* never reach here */
-    return ;
-}
-
-int main(void)
-{
-    /* disable interrupt first */
-    // rt_hw_interrupt_disable();
-
-    /* startup RT-Thread RTOS */
-    rtthread_startup();
-
-    return 0;
-}
-
-/*@}*/

+ 0 - 14
bsp/nrf52832/board/Sconscript

@@ -1,14 +0,0 @@
-Import('RTT_ROOT')
-Import('rtconfig')
-from building import *
-
-cwd     = GetCurrentDir()
-src	= Glob('*.c')
-CPPPATH = [cwd]
-
-#remove other no use files
-#SrcRemove(src, '*.c')
-
-group = DefineGroup('Board', src, depend = [''], CPPPATH = CPPPATH)
-
-Return('group')

+ 0 - 268
bsp/nrf52832/board/board.c

@@ -1,268 +0,0 @@
-#include "board.h"
-#include "uart.h"
-#include "app_util_platform.h"
-#include "nrf_drv_common.h"
-#include "nrf_systick.h"
-#include "nrf_rtc.h"
-#include "nrf_drv_clock.h"
-#include "softdevice_handler.h"
-#include "nrf_drv_uart.h"
-#include "nrf_gpio.h"
-
-#include <rtthread.h>
-#include <rthw.h>
-
-#if 0
-
-/*******************************************************************************
- * Function Name  : SysTick_Configuration
- * Description    : Configures the SysTick for OS tick.
- * Input          : None
- * Output         : None
- * Return         : None
- *******************************************************************************/
-void  SysTick_Configuration(void)
-{
-    nrf_drv_common_irq_enable(SysTick_IRQn, APP_TIMER_CONFIG_IRQ_PRIORITY);
-    nrf_systick_load_set(SystemCoreClock / RT_TICK_PER_SECOND);
-    nrf_systick_val_clear();
-    nrf_systick_csr_set(NRF_SYSTICK_CSR_CLKSOURCE_CPU | NRF_SYSTICK_CSR_TICKINT_ENABLE
-                        | NRF_SYSTICK_CSR_ENABLE);
-}
-
-/**
- * This is the timer interrupt service routine.
- *
- */
-
-
-void SysTick_Handler(void)
-{
-    if (rt_thread_self() != RT_NULL)
-    {
-    	/* enter interrupt */
-    	rt_interrupt_enter();
-
-    	rt_tick_increase();
-
-    	/* leave interrupt */
-    	rt_interrupt_leave();
-    }
-}
-
-#else
-
-#define TICK_RATE_HZ  RT_TICK_PER_SECOND
-#define SYSTICK_CLOCK_HZ  ( 32768UL )
-
-#define NRF_RTC_REG        NRF_RTC1
-    /* IRQn used by the selected RTC */
-#define NRF_RTC_IRQn       RTC1_IRQn
-    /* Constants required to manipulate the NVIC. */
-#define NRF_RTC_PRESCALER  ( (uint32_t) (ROUNDED_DIV(SYSTICK_CLOCK_HZ, TICK_RATE_HZ) - 1) )
-    /* Maximum RTC ticks */
-#define NRF_RTC_MAXTICKS   ((1U<<24)-1U)
-
-static volatile uint32_t m_tick_overflow_count = 0;
-#define NRF_RTC_BITWIDTH 24
-#define OSTick_Handler     RTC1_IRQHandler
-#define EXPECTED_IDLE_TIME_BEFORE_SLEEP   2
-
-void SysTick_Configuration(void)
-{
-    nrf_drv_clock_lfclk_request(NULL);
-
-    /* Configure SysTick to interrupt at the requested rate. */
-    nrf_rtc_prescaler_set(NRF_RTC_REG, NRF_RTC_PRESCALER);
-    nrf_rtc_int_enable   (NRF_RTC_REG, RTC_INTENSET_TICK_Msk);
-    nrf_rtc_task_trigger (NRF_RTC_REG, NRF_RTC_TASK_CLEAR);
-    nrf_rtc_task_trigger (NRF_RTC_REG, NRF_RTC_TASK_START);
-    nrf_rtc_event_enable(NRF_RTC_REG, RTC_EVTEN_OVRFLW_Msk);
-
-    NVIC_SetPriority(NRF_RTC_IRQn, 0xF);
-    NVIC_EnableIRQ(NRF_RTC_IRQn);
-}
-
-static rt_tick_t _tick_distance(void)
-{
-    nrf_rtc_event_clear(NRF_RTC_REG, NRF_RTC_EVENT_COMPARE_0);
-
-    uint32_t systick_counter = nrf_rtc_counter_get(NRF_RTC_REG);
-    nrf_rtc_event_clear(NRF_RTC_REG, NRF_RTC_EVENT_TICK);
-
-    /* check for overflow in TICK counter */
-    if(nrf_rtc_event_pending(NRF_RTC_REG, NRF_RTC_EVENT_OVERFLOW))
-    {
-        nrf_rtc_event_clear(NRF_RTC_REG, NRF_RTC_EVENT_OVERFLOW);
-        m_tick_overflow_count++;
-    }
-
-    return ((m_tick_overflow_count << NRF_RTC_BITWIDTH) + systick_counter) - rt_tick_get();
-}
-
-void OSTick_Handler( void )
-{
-    uint32_t diff;
-
-	/* enter interrupt */
-    rt_interrupt_enter();
-    diff = _tick_distance();
-
-    while((diff--) > 0)
-    {
-        if (rt_thread_self() != RT_NULL)
-        {
-          rt_tick_increase();
-        }
-    }
-    /* leave interrupt */
-    rt_interrupt_leave();
-}
-
-static void _wakeup_tick_adjust(void)
-{
-    uint32_t diff;
-    uint32_t level;
-
-    level = rt_hw_interrupt_disable();
-
-    diff = _tick_distance();
-
-    rt_tick_set(rt_tick_get() + diff);
-
-    if (rt_thread_self() != RT_NULL)
-    {
-    	struct rt_thread *thread;
-
-        /* check time slice */
-        thread = rt_thread_self();
-
-        if (thread->remaining_tick <= diff)
-        {
-            /* change to initialized tick */
-            thread->remaining_tick = thread->init_tick;
-
-            /* yield */
-            rt_thread_yield();
-        }
-        else
-        {
-            thread->remaining_tick -= diff;
-        }
-
-        /* check timer */
-        rt_timer_check();
-    }
-
-    rt_hw_interrupt_enable(level);
-}
-
-static void _sleep_ongo( uint32_t sleep_tick )
-{
-    uint32_t enterTime;
-    uint32_t entry_tick;
-
-    /* Make sure the SysTick reload value does not overflow the counter. */
-    if ( sleep_tick > NRF_RTC_MAXTICKS - EXPECTED_IDLE_TIME_BEFORE_SLEEP )
-    {
-        sleep_tick = NRF_RTC_MAXTICKS - EXPECTED_IDLE_TIME_BEFORE_SLEEP;
-    }
-
-    rt_enter_critical();
-
-    enterTime = nrf_rtc_counter_get(NRF_RTC_REG);
-
-    {
-        uint32_t wakeupTime = (enterTime + sleep_tick) & NRF_RTC_MAXTICKS;
-
-        /* Stop tick events */
-        nrf_rtc_int_disable(NRF_RTC_REG, NRF_RTC_INT_TICK_MASK);
-
-        /* Configure CTC interrupt */
-        nrf_rtc_cc_set(NRF_RTC_REG, 0, wakeupTime);
-        nrf_rtc_event_clear(NRF_RTC_REG, NRF_RTC_EVENT_COMPARE_0);
-        nrf_rtc_int_enable(NRF_RTC_REG, NRF_RTC_INT_COMPARE0_MASK);
-
-        entry_tick = rt_tick_get();
-
-        __DSB();
-
-        if ( sleep_tick > 0 )
-        {
-#ifdef SOFTDEVICE_PRESENT
-            if (softdevice_handler_is_enabled())
-            {
-                uint32_t err_code = sd_app_evt_wait();
-                APP_ERROR_CHECK(err_code);
-            }
-            else
-#endif
-            {
-                /* No SD -  we would just block interrupts globally.
-                * BASEPRI cannot be used for that because it would prevent WFE from wake up.
-                */
-                do{
-                    __WFE();
-                } while (0 == (NVIC->ISPR[0] | NVIC->ISPR[1]));
-            }
-        }
-
-        nrf_rtc_int_disable(NRF_RTC_REG, NRF_RTC_INT_COMPARE0_MASK);
-        nrf_rtc_event_clear(NRF_RTC_REG, NRF_RTC_EVENT_COMPARE_0);
-
-        _wakeup_tick_adjust();
-
-        /* Correct the system ticks */
-        {
-
-            nrf_rtc_event_clear(NRF_RTC_REG, NRF_RTC_EVENT_TICK);
-            nrf_rtc_int_enable (NRF_RTC_REG, NRF_RTC_INT_TICK_MASK);
-            /* It is important that we clear pending here so that our corrections are latest and in sync with tick_interrupt handler */
-            NVIC_ClearPendingIRQ(NRF_RTC_IRQn);
-        }
-
-        rt_kprintf("entry tick:%u, expected:%u, current tick:%u\n", entry_tick, sleep_tick, rt_tick_get());
-    }
-
-    rt_exit_critical();
-}
-
-#endif
-
-void rt_hw_system_powersave(void)
-{
-    uint32_t sleep_tick;
-
-    sleep_tick = rt_timer_next_timeout_tick() - rt_tick_get();
-
-    if ( sleep_tick >= EXPECTED_IDLE_TIME_BEFORE_SLEEP)
-    {
-        // rt_kprintf("sleep entry:%u\n", rt_tick_get());
-        _sleep_ongo( sleep_tick );
-    }
-}
-
-void rt_hw_board_init(void)
-{
-    // sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
-    /* Activate deep sleep mode */
-    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
-
-    nrf_drv_clock_init();
-    // nrf_drv_clock_hfclk_request(0);
-
-    SysTick_Configuration();
-
-    rt_thread_idle_sethook(rt_hw_system_powersave);
-
-    rt_hw_uart_init();
-
-#ifdef RT_USING_CONSOLE
-    rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
-#endif
-
-#ifdef RT_USING_COMPONENTS_INIT
-    rt_components_board_init();
-#endif
-}
-

+ 0 - 13
bsp/nrf52832/board/board.h

@@ -1,13 +0,0 @@
-#ifndef _BOARD_H_
-#define _BOARD_H_
-
-#include <rtthread.h>
-
-#include "nrf.h"
-
-#define CHIP_SRAM_END       (0x20000000 + 64*1024)
-
-void rt_hw_board_init(void);
-
-#endif
-

+ 0 - 289
bsp/nrf52832/board/uart.c

@@ -1,289 +0,0 @@
-#include "board.h"
-#include "uart.h"
-
-#include "nrf_drv_common.h"
-#include "nrf_drv_uart.h"
-#include "app_util_platform.h"
-#include "nrf_gpio.h"
-
-#include <rtdevice.h>
-
-static struct rt_serial_device _serial0_0;
-#if USE_UART0_1
-static struct rt_serial_device _serial0_1;
-#endif
-
-typedef struct
-{
-    struct rt_serial_device *serial;
-    nrf_drv_uart_t uart;
-    uint32_t rx_pin;
-    uint32_t tx_pin;
-} UART_CFG_T;
-
-UART_CFG_T uart0 = {
-    .uart = NRF_DRV_UART_INSTANCE(0),
-#ifdef RT_USING_CONSOLE
-    .rx_pin = 8,
-    .tx_pin = 6
-#else
-    .rx_pin = 19,
-    .tx_pin = 20
-#endif
-};
-
-#if USE_UART0_1
-UART_CFG_T uart1 = {
-    .uart = NRF_DRV_UART_INSTANCE(0),
-    .rx_pin = 3,
-    .tx_pin = 4
-};
-#endif
-
-UART_CFG_T *working_cfg = RT_NULL;
-
-void UART0_IRQHandler(void)
-{
-    if (nrf_uart_int_enable_check(NRF_UART0, NRF_UART_INT_MASK_ERROR)
-        && nrf_uart_event_check(NRF_UART0, NRF_UART_EVENT_ERROR))
-    {
-        nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_ERROR);
-    }
-
-    if (nrf_uart_int_enable_check(NRF_UART0, NRF_UART_INT_MASK_RXDRDY)
-        && nrf_uart_event_check(NRF_UART0, NRF_UART_EVENT_RXDRDY))
-    {
-        rt_hw_serial_isr(working_cfg->serial, RT_SERIAL_EVENT_RX_IND);
-    }
-
-    if (nrf_uart_int_enable_check(NRF_UART0, NRF_UART_INT_MASK_TXDRDY)
-        && nrf_uart_event_check(NRF_UART0, NRF_UART_EVENT_TXDRDY))
-    {
-        rt_hw_serial_isr(working_cfg->serial, RT_SERIAL_EVENT_TX_DONE);
-    }
-
-    if (nrf_uart_event_check(NRF_UART0, NRF_UART_EVENT_RXTO))
-    {
-        rt_hw_serial_isr(working_cfg->serial, RT_SERIAL_EVENT_RX_TIMEOUT);
-    }
-}
-
-static rt_err_t _uart_cfg(struct rt_serial_device *serial, struct serial_configure *cfg)
-{
-    nrf_drv_uart_config_t config = NRF_DRV_UART_DEFAULT_CONFIG;
-    UART_CFG_T *instance = &uart0;
-
-    RT_ASSERT(serial != RT_NULL);
-    RT_ASSERT(cfg != RT_NULL);
-
-    if (serial->parent.user_data != RT_NULL)
-    {
-        instance = (UART_CFG_T*)serial->parent.user_data;
-    }
-
-    nrf_uart_disable(instance->uart.reg.p_uart);
-
-    switch (cfg->baud_rate)
-    {
-    case 115200:
-        config.baudrate = NRF_UART_BAUDRATE_115200;
-        break;
-
-    case 9600:
-        config.baudrate = NRF_UART_BAUDRATE_9600;
-        break;
-
-    default:
-        config.baudrate = NRF_UART_BAUDRATE_115200;
-        break;
-    }
-
-    if (cfg->parity == PARITY_NONE)
-    {
-        config.parity = NRF_UART_PARITY_EXCLUDED;
-    }
-    else
-    {
-        config.parity = NRF_UART_PARITY_INCLUDED;
-    }
-
-    config.hwfc = NRF_UART_HWFC_DISABLED;
-    config.interrupt_priority = APP_IRQ_PRIORITY_LOWEST;
-    config.pselcts = 0;
-    config.pselrts = 0;
-    config.pselrxd = instance->rx_pin;
-    config.pseltxd = instance->tx_pin;
-
-    nrf_gpio_pin_set(config.pseltxd);
-    nrf_gpio_cfg_output(config.pseltxd);
-    nrf_gpio_pin_clear(config.pseltxd);
-    nrf_gpio_cfg_input(config.pselrxd, NRF_GPIO_PIN_NOPULL);
-    nrf_uart_baudrate_set(instance->uart.reg.p_uart, config.baudrate);
-    nrf_uart_configure(instance->uart.reg.p_uart, config.parity, config.hwfc);
-    nrf_uart_txrx_pins_set(instance->uart.reg.p_uart, config.pseltxd, config.pselrxd);
-
-    if (config.hwfc == NRF_UART_HWFC_ENABLED)
-    {
-        nrf_uart_hwfc_pins_set(instance->uart.reg.p_uart, config.pselrts, config.pselcts);
-    }
-
-    nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_TXDRDY);
-    nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_RXDRDY);
-    nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_RXTO);
-    nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_ERROR);
-
-    nrf_uart_int_enable(instance->uart.reg.p_uart, NRF_UART_INT_MASK_RXDRDY | NRF_UART_INT_MASK_RXTO | NRF_UART_INT_MASK_ERROR);
-    nrf_drv_common_irq_enable(nrf_drv_get_IRQn((void *)instance->uart.reg.p_uart), config.interrupt_priority);
-    nrf_uart_enable(instance->uart.reg.p_uart);
-    // nrf_uart_task_trigger(instance->uart.reg.p_uart, NRF_UART_TASK_STARTRX);
-    working_cfg = instance;
-    return RT_EOK;
-}
-
-static rt_err_t _uart_ctrl(struct rt_serial_device *serial, int cmd, void *arg)
-{
-    UART_CFG_T *instance = working_cfg;
-
-    RT_ASSERT(serial != RT_NULL);
-
-    if (serial->parent.user_data != RT_NULL)
-    {
-        instance = (UART_CFG_T*)serial->parent.user_data;
-    }
-
-    switch (cmd)
-    {
-        /* disable interrupt */
-    case RT_DEVICE_CTRL_CLR_INT:
-        nrf_uart_task_trigger(instance->uart.reg.p_uart, NRF_UART_TASK_STOPRX);
-        nrf_uart_int_disable(instance->uart.reg.p_uart, NRF_UART_INT_MASK_RXDRDY
-                                                | NRF_UART_INT_MASK_RXTO
-                                                | NRF_UART_INT_MASK_ERROR);
-        nrf_drv_common_irq_disable(nrf_drv_get_IRQn((void *)instance->uart.reg.p_uart));
-        break;
-
-        /* enable interrupt */
-    case RT_DEVICE_CTRL_SET_INT:
-        nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_RXDRDY);
-        nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_RXTO);
-        nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_ERROR);
-        /* Enable RX interrupt. */
-        nrf_uart_int_enable(instance->uart.reg.p_uart, NRF_UART_INT_MASK_RXDRDY
-                                                | NRF_UART_INT_MASK_RXTO
-                                                | NRF_UART_INT_MASK_ERROR);
-        nrf_drv_common_irq_enable(nrf_drv_get_IRQn((void *)instance->uart.reg.p_uart), APP_IRQ_PRIORITY_LOWEST);
-        nrf_uart_task_trigger(instance->uart.reg.p_uart, NRF_UART_TASK_STARTRX);
-        break;
-
-    case RT_DEVICE_CTRL_CUSTOM:
-        if ((rt_uint32_t)(arg) == UART_CONFIG_BAUD_RATE_9600)
-        {
-            instance->serial->config.baud_rate = 9600;
-            nrf_uart_baudrate_set(instance->uart.reg.p_uart, NRF_UART_BAUDRATE_9600);
-        }
-        else if ((rt_uint32_t)(arg) == UART_CONFIG_BAUD_RATE_115200)
-        {
-            instance->serial->config.baud_rate = 115200;
-            nrf_uart_baudrate_set(instance->uart.reg.p_uart, NRF_UART_BAUDRATE_115200);
-        }
-
-        // _uart_cfg(instance->serial, &(instance->serial->config));
-        // nrf_uart_task_trigger(instance->uart.reg.p_uart, NRF_UART_TASK_STARTRX);
-        break;
-
-    case RT_DEVICE_CTRL_PIN:
-        if (working_cfg != instance)
-        {
-            _uart_cfg(instance->serial, &(instance->serial->config));
-        }
-        break;
-
-    case RT_DEVICE_POWERSAVE:
-        nrf_uart_disable(instance->uart.reg.p_uart);
-        nrf_uart_txrx_pins_disconnect(instance->uart.reg.p_uart);
-        nrf_gpio_pin_clear(instance->rx_pin);
-        nrf_gpio_cfg_output(instance->rx_pin);
-        nrf_gpio_pin_clear(instance->tx_pin);
-        nrf_gpio_cfg_output(instance->tx_pin);
-        break;
-
-    case RT_DEVICE_WAKEUP:
-        _uart_cfg(instance->serial, &(instance->serial->config));
-        break;
-
-    default:
-        return RT_ERROR;
-    }
-
-    return RT_EOK;
-}
-
-static int _uart_putc(struct rt_serial_device *serial, char c)
-{
-    UART_CFG_T *instance = working_cfg;
-
-    RT_ASSERT(serial != RT_NULL);
-
-    if (serial->parent.user_data != RT_NULL)
-    {
-        instance = (UART_CFG_T*)serial->parent.user_data;
-    }
-
-    nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_TXDRDY);
-    nrf_uart_task_trigger(instance->uart.reg.p_uart, NRF_UART_TASK_STARTTX);
-    nrf_uart_txd_set(instance->uart.reg.p_uart, (uint8_t)c);
-    while (!nrf_uart_event_check(instance->uart.reg.p_uart, NRF_UART_EVENT_TXDRDY))
-    {
-    }
-
-    return 1;
-}
-
-static int _uart_getc(struct rt_serial_device *serial)
-{
-    int ch = -1;
-    UART_CFG_T *instance = working_cfg;
-
-    RT_ASSERT(serial != RT_NULL);
-
-    if (serial->parent.user_data != RT_NULL)
-    {
-        instance = (UART_CFG_T*)serial->parent.user_data;
-    }
-
-    if (nrf_uart_event_check(instance->uart.reg.p_uart, NRF_UART_EVENT_RXDRDY))
-    {
-        nrf_uart_event_clear(instance->uart.reg.p_uart, NRF_UART_EVENT_RXDRDY);
-        ch = (int)(nrf_uart_rxd_get(instance->uart.reg.p_uart));
-    }
-
-    return ch;
-}
-
-static struct rt_uart_ops _uart_ops = {
-    _uart_cfg,
-    _uart_ctrl,
-    _uart_putc,
-    _uart_getc
-};
-
-void rt_hw_uart_init(void)
-{
-    struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
-
-    config.bufsz = RT_SERIAL_RB_BUFSZ;
-    _serial0_0.config = config;
-    _serial0_0.ops = &_uart_ops;
-    uart0.serial = &_serial0_0;
-
-    rt_hw_serial_register(&_serial0_0, "uart0", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, &uart0);
-
-#if USE_UART0_1
-    config.bufsz = UART0_RB_SIZE;
-    _serial0_1.config = config;
-    _serial0_1.ops = &_uart_ops;
-    uart1.serial = &_serial0_1;
-    rt_hw_serial_register(&_serial0_1, "uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, &uart1);
-#endif
-}
-

+ 0 - 19
bsp/nrf52832/board/uart.h

@@ -1,19 +0,0 @@
-#ifndef _UART_H_
-#define _UART_H_
-
-#define RT_DEVICE_CTRL_CUSTOM   0x20
-#define RT_DEVICE_CTRL_PIN      0x21
-#define RT_DEVICE_POWERSAVE     0x22
-#define RT_DEVICE_WAKEUP        0x23
-
-#define UART_CONFIG_BAUD_RATE_9600      1
-#define UART_CONFIG_BAUD_RATE_115200    2
-
-#define UART0_RB_SIZE        1024
-
-// #define USE_UART0_1         0
-
-void rt_hw_uart_init(void);
-
-#endif
-

+ 0 - 34
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/Sconscript

@@ -1,34 +0,0 @@
-Import('RTT_ROOT')
-Import('rtconfig')
-from building import *
-
-# get current directory
-cwd = GetCurrentDir()
-
-BLE_COMMON = Glob('./components/ble/common/*.c')
-SrcRemove(BLE_COMMON, 'ble_conn_state.c')
-
-BLE_GATT = Glob('./components/ble/nrf_ble_gatt/*.c')
-BLE_ADVERTISING = Glob('./components/ble/ble_advertising/*.c')
-
-BLE_SERVICE = Glob('./components/ble/ble_services/ble_nus/*.c')
-
-BLE_SRC = BLE_COMMON + BLE_GATT + BLE_SERVICE + BLE_ADVERTISING
-
-SOFTDEVICE = Glob('./components/softdevice/common/softdevice_handler/*.c')
-SrcRemove(SOFTDEVICE, './components/softdevice/common/softdevice_handler/softdevice_handler_appsh.c')
-
-BLE_STACK_SRC = BLE_SRC + SOFTDEVICE
-
-path = [cwd + '/components']
-path += [cwd + '/components/softdevice/common/softdevice_handler']
-path += [cwd + '/components/softdevice/s132/headers']
-path += [cwd + '/components/softdevice/s132/headers/nrf52']
-path += [cwd + '/components/ble/common']
-path += [cwd + '/components/ble/nrf_ble_gatt']
-path += [cwd + '/components/ble/ble_advertising']
-path += [cwd + '/components/ble/ble_services/ble_nus']
-
-CPPDEFINES = ['BLE_STACK_SUPPORT_REQD', 'NRF_SD_BLE_API_VERSION=4', 'S132', 'SOFTDEVICE_PRESENT']
-group = DefineGroup('BLE_STACK', BLE_STACK_SRC, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
-Return('group')

+ 0 - 52
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/SConscript

@@ -1,52 +0,0 @@
-Import('RTT_ROOT')
-Import('rtconfig')
-from building import *
-
-# get current directory
-cwd = GetCurrentDir()
-
-DriversDir = cwd + '/drivers_nrf/'
-DeviceDrivers = [DriversDir + 'hal/nrf_saadc.c']
-DeviceDrivers += [DriversDir + 'common/nrf_drv_common.c']
-#DeviceDrivers += [DriversDir + 'uart/nrf_drv_uart.c']
-DeviceDrivers += [DriversDir + 'clock/nrf_drv_clock.c']
-DeviceDrivers += [DriversDir + 'gpiote/nrf_drv_gpiote.c']
-DeviceDrivers += [DriversDir + 'pwm/nrf_drv_pwm.c']
-DeviceDrivers += [DriversDir + 'saadc/nrf_drv_saadc.c']
-
-Libraries_dir = cwd + '/libraries/'
-Libraries_src = Glob(Libraries_dir + 'log/src/*.c')
-Libraries_src += Glob(Libraries_dir + 'timer/app_timer_rtthread.c')
-Libraries_src += Glob(Libraries_dir + 'util/*.c')
-Libraries_src += Glob(Libraries_dir + 'fstorage/fstorage.c')
-Libraries_src += Glob(Libraries_dir + 'strerror/nrf_strerror.c')
-
-src = DeviceDrivers + Libraries_src
-
-path = [cwd]
-path += [cwd + '/device']
-path += [cwd + '/drivers_nrf/delay']
-path += [cwd + '/drivers_nrf/uart']
-path += [cwd + '/drivers_nrf/clock']
-path += [cwd + '/drivers_nrf/gpiote']
-path += [cwd + '/drivers_nrf/common']
-path += [cwd + '/drivers_nrf/hal']
-path += [cwd + '/drivers_nrf/pwm']
-path += [DriversDir + 'saadc']
-
-path += [Libraries_dir + 'util']
-path += [Libraries_dir + 'timer']
-path += [Libraries_dir + 'fstorage']
-path += [Libraries_dir + 'experimental_section_vars']
-path += [Libraries_dir + 'log']
-path += [Libraries_dir + 'log/src']
-path += [Libraries_dir + 'strerror']
-
-path += [cwd + '/toolchain/cmsis/include']
-
-CPPDEFINES = ['RTTHREAD', 'SWI_DISABLE0', 'CONFIG_GPIO_AS_PINRESET', 'NRF52', 'NRF52832_XXAA']
-CPPDEFINES += ['NRF52_PAN_12', 'NRF52_PAN_15', 'NRF52_PAN_20', 'NRF52_PAN_31', 'NRF52_PAN_36']
-CPPDEFINES += ['NRF52_PAN_51', 'NRF52_PAN_54', 'NRF52_PAN_55', 'NRF52_PAN_58', 'NRF52_PAN_64', 'NRF52_PAN_74']
-
-group = DefineGroup('NRF_DRIVERS', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
-Return('group')

+ 0 - 86
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_channel_config/ant_channel_config.c

@@ -1,86 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_CHANNEL_CONFIG)
-#include "nrf_error.h"
-#include "ant_channel_config.h"
-#include "ant_interface.h"
-#include "ant_parameters.h"
-
-uint32_t ant_channel_init(ant_channel_config_t const * p_config)
-{
-    uint32_t err_code;
-    // Set Channel Number.
-    err_code = sd_ant_channel_assign(p_config->channel_number,
-                                     p_config->channel_type,
-                                     p_config->network_number,
-                                     p_config->ext_assign);
-
-    VERIFY_SUCCESS(err_code);
-
-    // Set Channel ID.
-    err_code = sd_ant_channel_id_set(p_config->channel_number,
-                                     p_config->device_number,
-                                     p_config->device_type,
-                                     p_config->transmission_type);
-
-    VERIFY_SUCCESS(err_code);
-
-    // Set Channel RF frequency.
-    err_code = sd_ant_channel_radio_freq_set(p_config->channel_number, p_config->rf_freq);
-    VERIFY_SUCCESS(err_code);
-
-    // Set Channel period.
-    if (!(p_config->ext_assign & EXT_PARAM_ALWAYS_SEARCH) && (p_config->channel_period != 0))
-    {
-        err_code = sd_ant_channel_period_set(p_config->channel_number, p_config->channel_period);
-    }
-
-
-#if ANT_CONFIG_ENCRYPTED_CHANNELS > 0
-    VERIFY_SUCCESS(err_code);
-
-    err_code = ant_channel_encrypt_config(p_config->channel_type , p_config->channel_number, p_config->p_crypto_settings);
-#endif
-
-    return err_code;
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_CHANNEL_CONFIG)

+ 0 - 98
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_channel_config/ant_channel_config.h

@@ -1,98 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_CHANNEL_CONFIG_H__
-#define ANT_CHANNEL_CONFIG_H__
-
-/** @file
- *
- * @defgroup ant_channel_config ANT channel configuration
- * @{
- * @ingroup ant_sdk_utils
- * @brief ANT channel configuration module.
- */
-
-#include <stdint.h>
-#include "sdk_config.h"
-
-
-#ifndef ANT_CONFIG_ENCRYPTED_CHANNELS
-    #error Undefined ANT_CONFIG_ENCRYPTED_CHANNELS. It should be defined in sdk_config.h file.
-#elif ANT_CONFIG_ENCRYPTED_CHANNELS > 0
-    #include "ant_encrypt_config.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief ANT channel configuration structure. */
-typedef struct
-{
-    uint8_t  channel_number;        ///< Assigned channel number.
-    uint8_t  channel_type;          ///< Channel type (see Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
-    uint8_t  ext_assign;            ///< Extended assign (see Ext. Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
-    uint8_t  rf_freq;               ///< Radio frequency offset from 2400 MHz (for example, 2466 MHz, rf_freq = 66).
-    uint8_t  transmission_type;     ///< Transmission type.
-    uint8_t  device_type;           ///< Device type.
-    uint16_t device_number;         ///< Device number.
-    uint16_t channel_period;        ///< The period in 32 kHz counts.
-    uint8_t  network_number;        ///< Network number denoting the network key.
-
-#if ANT_CONFIG_ENCRYPTED_CHANNELS > 0
-    ant_encrypt_channel_settings_t * p_crypto_settings; ///< Pointer to cryptographic settings, NULL if this configuration have to be omitted.
-#endif
-
-} ant_channel_config_t;
-
-/**@brief Function for configuring the ANT channel.
- *
- * @param[in]  p_config        Pointer to the channel configuration structure.
- *
- * @retval     NRF_SUCCESS     If the channel was successfully configured. Otherwise, an error code is returned.
- */
-uint32_t ant_channel_init(ant_channel_config_t const * p_config);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_CHANNEL_CONFIG_H__
-/** @} */

+ 0 - 239
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_encryption/ant_encrypt_config.c

@@ -1,239 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_ENCRYPT_CONFIG)
-#include <stdlib.h>
-#include "ant_encrypt_config.h"
-#include "ant_interface.h"
-#include "ant_parameters.h"
-
-#ifdef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED
-    #include "ant_encrypt_negotiation_slave.h"
-#endif
-
- /*lint -e551 -save*/
-/** Flag for checking if stack was configured for encryption. */
-static bool m_stack_encryption_configured = false;
- /*lint -restore */
-
- /** Pointer to handler of module's events. */
-static ant_encryp_user_handler_t m_ant_enc_evt_handler = NULL;
-
-static ret_code_t ant_enc_advance_burs_config_apply(
-    ant_encrypt_adv_burst_settings_t const * const p_adv_burst_set);
-
-ret_code_t ant_stack_encryption_config(ant_encrypt_stack_settings_t const * const p_crypto_set)
-{
-    ret_code_t err_code;
-
-    for ( uint32_t i = 0; i < p_crypto_set->key_number; i++)
-    {
-        err_code = sd_ant_crypto_key_set(i, p_crypto_set->pp_key[i]);
-        VERIFY_SUCCESS(err_code);
-    }
-
-    if (p_crypto_set->p_adv_burst_config != NULL)
-    {
-        err_code = ant_enc_advance_burs_config_apply(p_crypto_set->p_adv_burst_config);
-        VERIFY_SUCCESS(err_code);
-    }
-
-    // subcomands LUT for @ref sd_ant_crypto_info_set calls
-    const uint8_t set_enc_info_param_lut[] =
-    {
-        ENCRYPTION_INFO_SET_CRYPTO_ID,
-        ENCRYPTION_INFO_SET_CUSTOM_USER_DATA,
-        ENCRYPTION_INFO_SET_RNG_SEED
-    };
-
-    for ( uint32_t i = 0; i < sizeof(set_enc_info_param_lut); i++)
-    {
-        if ( p_crypto_set->info.pp_array[i] != NULL)
-        {
-            err_code = sd_ant_crypto_info_set(set_enc_info_param_lut[i],
-                                              p_crypto_set->info.pp_array[i]);
-
-            VERIFY_SUCCESS(err_code);
-        }
-    }
-
-    #ifdef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED
-        // all ANT channels have unsupported slave encryption tracking (even master's channel)
-        ant_channel_encryp_negotiation_slave_init();
-    #endif
-
-    m_ant_enc_evt_handler = NULL;
-
-    m_stack_encryption_configured = true;
-
-    return NRF_SUCCESS;
-}
-
-
-/**
- * @brief Function for configuring advanced burst settings according to encryption requirements.
- *
- * @param p_adv_burst_set  Pointer to ANT advanced burst settings.
- *
- * @retval Value returned by @ref sd_ant_adv_burst_config_set.
- */
-static ret_code_t ant_enc_advance_burs_config_apply(
-    ant_encrypt_adv_burst_settings_t const * const p_adv_burst_set)
-{
-    uint8_t adv_burst_conf_str[ADV_BURST_CFG_MIN_SIZE] =
-    { ADV_BURST_MODE_ENABLE, 0, 0, 0, 0, 0, 0, 0 };
-
-    adv_burst_conf_str[ADV_BURST_CFG_PACKET_SIZE_INDEX] = p_adv_burst_set->packet_length;
-    adv_burst_conf_str[ADV_BURST_CFG_REQUIRED_FEATURES] = p_adv_burst_set->required_feature;
-    adv_burst_conf_str[ADV_BURST_CFG_OPTIONAL_FEATURES] = p_adv_burst_set->optional_feature;
-
-    return sd_ant_adv_burst_config_set(adv_burst_conf_str, sizeof(adv_burst_conf_str));
-}
-
-
-ret_code_t ant_channel_encrypt_config_perform(uint8_t                          channel_number,
-                                              ant_encrypt_channel_settings_t * p_crypto_config)
-{
-    return sd_ant_crypto_channel_enable(channel_number,
-                                        p_crypto_config->mode,
-                                        p_crypto_config->key_index,
-                                        p_crypto_config->decimation_rate);
-}
-
-
-ret_code_t ant_channel_encrypt_config(uint8_t                          channel_type,
-                                      uint8_t                          channel_number,
-                                      ant_encrypt_channel_settings_t * p_crypto_config)
-{
-    ret_code_t err_code;
-
-    if (p_crypto_config != NULL)
-    {
-        // encryption of the stack should be initialized previously
-        if (m_stack_encryption_configured == false)
-        {
-            return NRF_ERROR_MODULE_NOT_INITIALZED;
-        }
-
-        switch (channel_type)
-        {
-            case CHANNEL_TYPE_MASTER:
-                err_code = ant_channel_encrypt_config_perform(channel_number, p_crypto_config);
-#ifdef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED
-                ant_channel_encryp_tracking_state_set(channel_number,
-                                                      ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED);
-#endif
-                break;
-
-#ifdef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED
-            case CHANNEL_TYPE_SLAVE:
-                ant_slave_channel_encrypt_config(channel_number, p_crypto_config);
-
-                if (p_crypto_config->mode == ENCRYPTION_DISABLED_MODE)
-                {
-                    err_code = ant_channel_encrypt_config_perform(channel_number, p_crypto_config);
-                    ant_channel_encryp_tracking_state_set(channel_number,
-                                                          ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED);
-                }
-                else
-                {
-                    ant_channel_encryp_tracking_state_set(channel_number,
-                                                          ANT_ENC_CHANNEL_STAT_NOT_TRACKING);
-                    err_code = NRF_SUCCESS;
-                }
-                break;
-#endif
-
-            default:
-                err_code = NRF_ERROR_INVALID_PARAM;
-                break;
-        }
-    }
-    else
-    {
-#ifdef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED
-        ant_channel_encryp_tracking_state_set(channel_number,
-                                              ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED);
-#endif
-        err_code = NRF_SUCCESS;
-    }
-
-    return err_code;
-}
-
-/** @brief Function for calling the handler of module events.*/
-static void ant_encrypt_user_handler_try_to_run(uint8_t ant_channel, ant_encrypt_user_evt_t event)
-{
-    if (m_ant_enc_evt_handler != NULL)
-    {
-        m_ant_enc_evt_handler(ant_channel, event);
-    }
-}
-
-void ant_encrypt_event_handler(ant_evt_t * p_ant_evt)
-{
-    uint8_t const ant_channel = p_ant_evt->channel;
-
-#ifdef ANT_ENCRYPT_NEGOTIATION_SLAVE_ENABLED
-    ant_slave_encrypt_negotiation(p_ant_evt);
-#endif
-
-    switch (p_ant_evt->event)
-    {
-        case EVENT_RX_FAIL_GO_TO_SEARCH:
-            ant_encrypt_user_handler_try_to_run(ant_channel, ANT_ENC_EVT_CHANNEL_LOST);
-            break;
-
-        case EVENT_ENCRYPT_NEGOTIATION_SUCCESS:
-             ant_encrypt_user_handler_try_to_run(ant_channel, ANT_ENC_EVT_NEGOTIATION_SUCCESS);
-             break;
-
-        case EVENT_ENCRYPT_NEGOTIATION_FAIL:
-            ant_encrypt_user_handler_try_to_run(ant_channel, ANT_ENC_EVT_NEGOTIATION_FAIL);
-            break;
-    }
-}
-
-void ant_enc_event_handler_register(ant_encryp_user_handler_t user_handler_func)
-{
-    m_ant_enc_evt_handler = user_handler_func;
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_ENCRYPT_CONFIG)

+ 0 - 255
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_encryption/ant_encrypt_config.h

@@ -1,255 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_ENCRYPT_CONFIG__
-#define ANT_ENCRYPT_CONFIG__
-
-/**@file
- *
- * @defgroup ant_encrypt_config ANT encryption configuration
- * @{
- * @ingroup  ant_sdk_utils
- *
- * @brief    Encryption configuration for the ANT stack and channels.
- *
- */
-
-#include <stdint.h>
-
-#include "sdk_errors.h"
-#include "ant_stack_handler_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** @name Advanced burst configuration for encryption modules
- * @{
- */
-#define ADV_BURST_CFG_MIN_SIZE          8 ///< Minimum size of the advance burst configuration data.
-#define ADV_BURST_CFG_PACKET_SIZE_INDEX 1 ///< Index of the packet size field in the configuration data.
-#define ADV_BURST_CFG_REQUIRED_FEATURES 2 ///< Index of the required features field in the configuration data.
-#define ADV_BURST_CFG_OPTIONAL_FEATURES 5 ///< Index of the optional features field in the configuration data.
-/**@} */
-
-/** @brief ANT channel cryptographic configuration. */
-typedef struct
-{
-    uint8_t mode;            ///< Encryption mode. See the encrypted channel defines in ant_parameters.h.
-    uint8_t key_index;       ///< Index of encryption key.
-    uint8_t decimation_rate; ///< Division of the master channel rate by the slave’s tracking channel rate.
-} ant_encrypt_channel_settings_t;
-
-/** @brief ANT encryption information. */
-typedef union
-{
-    uint8_t * pp_array[3]; // For array access support.
-    struct
-    {
-        uint8_t * p_encryption_id;   ///< Pointer to the encryption ID of the device (4 bytes).
-        uint8_t * p_user_info;       ///< Pointer to the user information string (19 bytes).
-        uint8_t * p_random_num_seed; ///< Pointer to the random number seed (16 bytes).
-    } items;
-} ant_encrypt_info_settings_t;
-
-/** @brief Advanced burst settings used by the encrypted channel. */
-typedef struct
-{
-    uint8_t packet_length;    ///< RF payload size. See the advanced burst configuration defines in ant_parameters.h.
-    uint8_t required_feature; ///< Required advanced burst modes. See the advanced burst configuration defines in ant_parameters.h.
-    uint8_t optional_feature; ///< Optional advanced burst modes. See the advanced burst configuration defines in ant_parameters.h.
-} ant_encrypt_adv_burst_settings_t;
-
-/**@brief ANT stack cryptographic configuration. */
-typedef struct
-{
-    ant_encrypt_info_settings_t        info;               ///< Pointer to the encryption information structure.
-    uint8_t                        * * pp_key;             ///< Pointer to an array for pointers to encryption keys. Each key must have a length of 16 bytes.
-    uint8_t                            key_number;         ///< Number of encryption keys.
-    ant_encrypt_adv_burst_settings_t * p_adv_burst_config; ///< Advanced burst configuration. If NULL, the advanced burst must be configured externally.
-} ant_encrypt_stack_settings_t;
-
-/**
- * @brief ANT encryption negotiation events.
- */
-typedef enum
-{
-    ANT_ENC_EVT_NEGOTIATION_SUCCESS, ///< Negotiation success.
-    ANT_ENC_EVT_NEGOTIATION_FAIL,    ///< Negotiation failure.
-    ANT_ENC_EVT_CHANNEL_LOST         ///< Lost a channel. It's relevant only for slave channels.
-} ant_encrypt_user_evt_t;
-
-/**
- * @brief Event handler for ANT encryption user events.
- */
-typedef void (* ant_encryp_user_handler_t)(uint8_t channel, ant_encrypt_user_evt_t event);
-
-/**
- * @brief Macro for initializing an ANT encryption information structure.
- *
- * @param[in] P_ENC_ID         Pointer to the encryption ID of the device (4 bytes).
- * @param[in] P_USER_INFO      Pointer to the user information string (19 bytes).
- * @param[in] P_RAND_NUM_SEED  Pointer to the random number seed (16 bytes).
- */
-#define ANT_CRYPTO_INFO_SETTINGS_INIT(P_ENC_ID, P_USER_INFO, P_RAND_NUM_SEED) \
-    {                                                                         \
-        .items =                                                              \
-        {                                                                     \
-            .p_encryption_id   = P_ENC_ID,                                    \
-            .p_user_info       = P_USER_INFO,                                 \
-            .p_random_num_seed = P_RAND_NUM_SEED                              \
-        }                                                                     \
-    }
-
-/**
- * @brief Macro for declaring the basic cryptographic configuration for the ANT stack.
- *
- * This macro configures the following settings:
- * - Cryptographic key
- * - Encryption ID
- * - Advanced burst mode with the maximum RF payload size
- *
- * Use @ref ANT_ENCRYPT_STACK_SETTINGS_BASE to access the created configuration instance.
- *
- * @param[in] NAME   Name for the created data instance.
- * @param[in] P_KEY  Pointer to the cryptographic key (16 bytes).
- * @param[in] P_ENC_ID Pointer to the encryption ID (4 bytes).
- */
-#define ANT_ENCRYPT_STACK_SETTINGS_BASE_DEF(NAME, P_KEY, P_ENC_ID)                 \
-    ant_encrypt_adv_burst_settings_t NAME##_ant_enc_adv_burst_set =                \
-    {                                                                              \
-        .packet_length    = ADV_BURST_MODES_MAX_SIZE,                              \
-        .required_feature = 0,                                                     \
-        .optional_feature = 0                                                      \
-    };                                                                             \
-    uint8_t                    * pp_##NAME##_key[1] = {P_KEY};                     \
-    ant_encrypt_stack_settings_t NAME ## _ant_crypto_settings =                    \
-    {                                                                              \
-        .info               = ANT_CRYPTO_INFO_SETTINGS_INIT(P_ENC_ID, NULL, NULL), \
-        .pp_key             = pp_##NAME##_key,                                     \
-        .key_number         = 1,                                                   \
-        .p_adv_burst_config = &NAME##_ant_enc_adv_burst_set                        \
-    }
-
-
-/** @brief Macro for accessing the configuration instance created
- *  by @ref ANT_ENCRYPT_STACK_SETTINGS_BASE_DEF.
- *
- * @param[in] NAME   Name of the settings instance.
- */
-#define ANT_ENCRYPT_STACK_SETTINGS_BASE(NAME) (NAME##_ant_crypto_settings)
-
-/**
- * @brief Function for applying an encryption configuration to a slave channel.
- *
- * This function enables encryption on a channel.
- *
- * This function should be used by the @ref ant_encrypt_negotiation_slave module and this module.
- *
- * @param[in] channel_number   ANT channel number.
- * @param[in] p_crypto_config  Pointer to the encryption configuration.
- *
- * @return Value returned by @ref sd_ant_crypto_channel_enable (for example, NRF_SUCCESS if
- * the configuration was successful).
- */
-ret_code_t ant_channel_encrypt_config_perform(uint8_t                          channel_number,
-                                              ant_encrypt_channel_settings_t * p_crypto_config);
-
-/**
- * @brief Function for applying an encryption configuration to a master or slave channel.
- *
- * When called for a master channel, this function enables encryption
- * for that channel. When called for a slave channel, it saves
- * the encryption configuration for future use.
- *
- * This function should be used by the @ref ant_channel_config module.
- *
- * @param[in] channel_type     ANT channel type: CHANNEL_TYPE_SLAVE or CHANNEL_TYPE_MASTER.
- * @param[in] channel_num      ANT channel number.
- * @param[in] p_crypto_config  Pointer to the encryption configuration.
- *
- * @retval NRF_SUCCESS                      If the function completed successfully.
- * @retval NRF_ERROR_INVALID_PARAM          If the channel type is invalid.
- * @retval NRF_ERROR_MODULE_NOT_INITIALZED  If the stack is not configured for encryption.
- * @retval Other                            Otherwise, the error value returned by the @ref
- *                                          ant_channel_encrypt_config_perform function is returned.
- */
-ret_code_t ant_channel_encrypt_config(uint8_t                          channel_type,
-                                      uint8_t                          channel_num,
-                                      ant_encrypt_channel_settings_t * p_crypto_config);
-
-/**
- * @brief Function for configuring the cryptographic settings of the ANT stack.
- *
- * @param[in] p_crypto_info_set Pointer to the settings.
- */
-ret_code_t ant_stack_encryption_config(ant_encrypt_stack_settings_t const * const p_crypto_info_set);
-
-
-/**
- * @brief Function for handling ANT encryption events.
- *
- * This function should be used directly in the ANT event dispatching process.
- * It serves the ANT encryption events to the registered event handler.
- * If @ref ant_encrypt_negotiation_slave is used, this function is required.
- *
- * This function should be used by the @ref ant_encrypt_config module.
- *
- * @param[in] p_ant_evt  Pointer to the ANT stack event message structure.
- */
-void ant_encrypt_event_handler(ant_evt_t * p_ant_evt);
-
-/**
- * @brief Function for registering an event handler for ANT encryption events.
- *
- * The event handler should support all of the events in @ref ant_encrypt_user_evt_t.
- *
- * @param[in] p_handler Pointer to a handler function.
- */
-void ant_enc_event_handler_register(ant_encryp_user_handler_t p_handler);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_ENCRYPT_CONFIG__

+ 0 - 189
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_encryption/ant_encrypt_negotiation_slave.c

@@ -1,189 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_ENCRYPT_NEGOTIATION_SLAVE)
-#include <stdlib.h>
-#include <string.h>
-#include "ant_encrypt_config.h"
-#include "ant_interface.h"
-#include "ant_parameters.h"
-#include "nrf_error.h"
-#include "app_error.h"
-
-#include "ant_encrypt_negotiation_slave.h"
-
-/** Number of supported channels. */
-#define NUMBER_OF_CHANNELS (ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED)
-
-/** Flag to block other channels from attempting to enable encryption while
- * another encryption is in the process.
- */
-static volatile bool m_can_enable_crypto = true;
-
-/** Array to keep track of which channels are currently tracking. */
-static ant_encrypt_tracking_state_t m_encrypt_channel_states[NUMBER_OF_CHANNELS];
-
-/** Array for the slave channels' encryption settings. */
-static ant_encrypt_channel_settings_t m_slave_channel_conf[MAX_ANT_CHANNELS];
-
-
-
-void ant_channel_encryp_tracking_state_set(uint8_t                      channel_number,
-                                           ant_encrypt_tracking_state_t state)
-{
-    m_encrypt_channel_states[channel_number] = state;
-}
-
-
-void ant_channel_encryp_negotiation_slave_init(void)
-{
-    for (uint32_t channel = 0; channel < NUMBER_OF_CHANNELS; channel++)
-    {
-        ant_channel_encryp_tracking_state_set(channel, ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED);
-    }
-
-    m_can_enable_crypto   = true;
-}
-
-
-ant_encrypt_tracking_state_t ant_channel_encryp_tracking_state_get(uint8_t channel_number)
-{
-    return m_encrypt_channel_states[channel_number];
-}
-
-
-void ant_slave_channel_encrypt_config(uint8_t                                      channel_number,
-                                      ant_encrypt_channel_settings_t const * const p_crypto_config)
-{
-    memcpy(&m_slave_channel_conf[channel_number], p_crypto_config,
-           sizeof(ant_encrypt_channel_settings_t));
-}
-
-
-/**@brief Function for handling ANT RX channel events.
- *
- * @param[in] p_event_message_buffer The ANT event message buffer.
- */
-static void ant_slave_encrypt_try_enable(uint8_t ant_channel,
-                                         uint8_t ant_message_id)
-{
-    uint32_t                     err_code;
-    ant_encrypt_tracking_state_t track_stat;
-
-
-    switch (ant_message_id)
-    {
-        // Broadcast data received.
-        case MESG_BROADCAST_DATA_ID:
-
-            track_stat = ant_channel_encryp_tracking_state_get(ant_channel);
-            // If the encryption has not yet been negotiated for this channel and another channel
-            // is not currently trying to enable encryption, enable encryption
-            if ((track_stat != ANT_ENC_CHANNEL_STAT_TRACKING_DECRYPTED)
-                && (track_stat != ANT_ENC_CHANNEL_STAT_NEGOTIATING)
-                && m_can_enable_crypto)
-            {
-                // Block other channels from trying to enable encryption until this channel
-                // is finished
-                m_can_enable_crypto = false;
-                ant_channel_encryp_tracking_state_set(ant_channel,
-                                                      ANT_ENC_CHANNEL_STAT_NEGOTIATING);
-
-                // Enable encryption on ant_channel
-                err_code =
-                    ant_channel_encrypt_config_perform(ant_channel,
-                                                       &m_slave_channel_conf[ant_channel]);
-                APP_ERROR_CHECK(err_code);
-            }
-            break;
-
-        default:
-            break;
-    }
-}
-
-
-void ant_slave_encrypt_negotiation(ant_evt_t * p_ant_evt)
-{
-
-    uint8_t const ant_channel = p_ant_evt->channel;
-    ANT_MESSAGE               * p_ant_msg;
-
-    ant_encrypt_tracking_state_t track_state = ant_channel_encryp_tracking_state_get(ant_channel);
-
-    if (track_state == ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED)
-        return;
-
-    switch (p_ant_evt->event)
-    {
-        case EVENT_RX_FAIL_GO_TO_SEARCH:
-            if (track_state == ANT_ENC_CHANNEL_STAT_NEGOTIATING)
-            {
-                m_can_enable_crypto = true;
-            }
-
-            ant_channel_encryp_tracking_state_set(ant_channel, ANT_ENC_CHANNEL_STAT_NOT_TRACKING);
-            break;
-
-        case EVENT_RX:
-            /*lint -e545 -save*/
-            p_ant_msg = (ANT_MESSAGE *) &(p_ant_evt->msg.evt_buffer);
-            /*lint -restore*/
-            ant_slave_encrypt_try_enable(ant_channel, p_ant_msg->ANT_MESSAGE_ucMesgID);
-            break;
-
-        case EVENT_ENCRYPT_NEGOTIATION_SUCCESS:
-            m_can_enable_crypto = true;
-            ant_channel_encryp_tracking_state_set(ant_channel,
-                                                  ANT_ENC_CHANNEL_STAT_TRACKING_DECRYPTED);
-            break;
-
-        case EVENT_ENCRYPT_NEGOTIATION_FAIL:
-            m_can_enable_crypto = true;
-            ant_channel_encryp_tracking_state_set(ant_channel,
-                                                  ANT_ENC_CHANNEL_STAT_TRACKING_ENCRYPTED);
-            break;
-
-        default:
-            break;
-    }
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_ENCRYPT_NEGOTIATION_SLAVE)

+ 0 - 140
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_encryption/ant_encrypt_negotiation_slave.h

@@ -1,140 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_ENCRYPT_NEGOTIATION_SLAVE_H__
-#define ANT_ENCRYPT_NEGOTIATION_SLAVE_H__
-
-/**@file
- *
- * @defgroup ant_encrypt_negotiation_slave ANT encryption negotiation
- * @{
- * @ingroup  ant_sdk_utils
- *
- * @brief    Encryption negotiation for encrypted ANT slave channels.
- *
- * After pairing, the slave starts negotiating the encryption with the master. After
- * successful negotiation, the slave can decrypt messages from the master, and all
- * future messages are sent encrypted.
- *
- */
-
-#include <stdint.h>
-#include "ant_stack_handler_types.h"
-#include "ant_encrypt_config.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** Encryption negotiation states for a slave channel. */
-typedef enum
-{
-    ANT_ENC_CHANNEL_STAT_NOT_TRACKING,        ///< Not tracking the master.
-    ANT_ENC_CHANNEL_STAT_TRACKING_ENCRYPTED,  ///< Tracking the master, but cannot decrypt messages.
-    ANT_ENC_CHANNEL_STAT_NEGOTIATING,         ///< Encryption has been enabled and negotiation is in progress.
-    ANT_ENC_CHANNEL_STAT_TRACKING_DECRYPTED,  ///< Tracking the master and can decrypt messages.
-    ANT_ENC_CHANNEL_STAT_TRACKING_UNSUPPORTED ///< Tracking unsupported on this channel.
-} ant_encrypt_tracking_state_t;
-
-
-/**
- * @brief Function for setting the encryption negotiation state of a slave ANT channel.
- *
- * This function should be used by the @ref ant_encrypt_config module.
- *
- * @param[in] channel_number    ANT channel number.
- * @param[in] state             State to set.
- */
-void ant_channel_encryp_tracking_state_set(uint8_t                      channel_number,
-                                           ant_encrypt_tracking_state_t state);
-
-/**
- * @brief Function for getting the encryption negotiation state of a slave ANT channel.
- *
- * @param[in] channel_number       ANT channel number.
- */
-ant_encrypt_tracking_state_t ant_channel_encryp_tracking_state_get(uint8_t channel_number);
-
-/**
- * @brief Function for initializing the module.
- *
- * This function initializes internal states of the module. It should
- * only be used by the @ref ant_encrypt_config module.
- *
- */
-void ant_channel_encryp_negotiation_slave_init(void);
-
-/**
- * @brief Function for setting the configuration for the slave channel.
- *
- * This function saves the channel's encryption configuration to a lookup table (LUT) for
- * future usage. The configuration can then be used to enable encryption.
- *
- * This function is intended to be used by the @ref ant_encrypt_config module.
- *
- * @param[in] channel_number   ANT channel number.
- * @param[in] p_crypto_config  Pointer to the encryption configuration.
- */
-void ant_slave_channel_encrypt_config(uint8_t                                      channel_number,
-                                      ant_encrypt_channel_settings_t const * const p_crypto_config);
-
-
-/**
- * @brief Function for handling ANT encryption negotiation on slave nodes.
- *
- * This function should be used directly in the ANT event dispatching process. It
- * tries to enable slave channel encryption for all slave channels that are declared
- * as encrypted channels (if appropriate master channels are found).
- *
- * This function should be used by the @ref ant_encrypt_config module.
- *
- * @param[in] p_ant_evt  Pointer to the ANT stack event message structure.
- */
-void ant_slave_encrypt_negotiation(ant_evt_t * p_ant_evt);
-
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_ENCRYPT_NEGOTIATION_SLAVE_H__

+ 0 - 2379
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/antfs.c

@@ -1,2379 +0,0 @@
-/**
- * This software is subject to the ANT+ Shared Source License
- * www.thisisant.com/swlicenses
- * Copyright (c) Dynastream Innovations, Inc. 2012
- * 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 Dynastream nor the names of its
- *    contributors may be used to endorse or promote products
- *    derived from this software without specific prior
- *    written permission.
- * 
- * The following actions are prohibited:
- * 1) Redistribution of source code containing the ANT+ Network
- *    Key. The ANT+ Network Key is available to ANT+ Adopters.
- *    Please refer to http://thisisant.com to become an ANT+
- *    Adopter and access the key.
- * 
- * 2) Reverse engineering, decompilation, and/or disassembly of
- *    software provided in binary form under this 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 HEREBY
- * 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; DAMAGE TO ANY DEVICE, 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. SOME STATES DO NOT ALLOW
- * THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE
- * ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANTFS)
-
-#include "antfs.h"
-#include <string.h>
-#include "defines.h"
-#include "app_error.h"
-#include "app_timer.h"
-#include "ant_error.h"
-#include "ant_parameters.h"
-#include "ant_interface.h"
-#include "ant_key_manager.h"
-#include "crc.h"
-
-#if ANTFS_CONFIG_DEBUG_LED_ENABLED
-    #include "bsp.h"
-#endif // ANTFS_CONFIG_DEBUG_LED_ENABLED
-
-#define BURST_PACKET_SIZE                  8u                            /**< The burst packet size. */
-
-#define ANTFS_CONNECTION_TYPE_OFFSET       0x00u                         /**< The connection type offset within ANT-FS message. */
-#define ANTFS_COMMAND_OFFSET               0x01u                         /**< The command offset within ANT-FS message. */
-#define ANTFS_RESPONSE_OFFSET              0x01u                         /**< The response offset within ANT-FS message. */
-
-#define ANTFS_CONTROL_OFFSET               0x02u                         /**< The control offset within ANT-FS message. */
-#define ANTFS_DATA_OFFSET                  0x03u                         /**< The data offset within ANT-FS message. */
-
-#define ANTFS_BEACON_ID                    0x43u                         /**< The ANT-FS beacon ID. */
-#define ANTFS_COMMAND_ID                   0x44u                         /**< The ANT-FS command ID. */
-
-// Beacon definitions.
-#define STATUS1_OFFSET                     0x01u                         /**< The beacon status1 field offset. */
-#define STATUS2_OFFSET                     0x02u                         /**< The beacon status2 field offset. */
-   #define DEVICE_STATE_SHIFT              0x00u                         /**< Shift value for device state bitfield. */
-   #define DEVICE_STATE_MASK               (0x0Fu << DEVICE_STATE_SHIFT) /**< Device state bitmask. */
-   #define DEVICE_STATE_LINK               (0x00u << DEVICE_STATE_SHIFT) /**< Device is in link state. */
-   #define DEVICE_STATE_AUTHENTICATE       (0x01u << DEVICE_STATE_SHIFT) /**< Device is in authenticate state. */
-   #define DEVICE_STATE_TRANSPORT          (0x02u << DEVICE_STATE_SHIFT) /**< Device is in transport state. */
-   #define DEVICE_STATE_BUSY               (0x03u << DEVICE_STATE_SHIFT) /**< Device is in busy state. */
-
-#define DEVICE_DESCRIPTOR_OFFSET_0         0x04u                         /**< Beacon ANT-FS device descriptor LSB position. */
-#define DEVICE_DESCRIPTOR_OFFSET_1         0x05u                         /**< Beacon ANT-FS device descriptor LSB + 1 position. */
-#define DEVICE_DESCRIPTOR_OFFSET_2         0x06u                         /**< Beacon ANT-FS device descriptor LSB + 2 position. */
-#define DEVICE_DESCRIPTOR_OFFSET_3         0x07u                         /**< Beacon ANT-FS device descriptor MSB position. */
-
-// Commands.
-#define ANTFS_CMD_NONE                     0x00u                         /**< Used to identify that no ANT-FS command is in progress. */
-#define ANTFS_CMD_LINK_ID                  0x02u                         /**< ANT-FS link command ID. */
-#define ANTFS_CMD_DISCONNECT_ID            0x03u                         /**< ANT-FS disconnect command ID. */
-#define ANTFS_CMD_AUTHENTICATE_ID          0x04u                         /**< ANT-FS authenticate command ID. */
-#define ANTFS_CMD_PING_ID                  0x05u                         /**< ANT-FS ping command ID. */
-#define ANTFS_CMD_DOWNLOAD_ID              0x09u                         /**< ANT-FS download request command ID. */
-#define ANTFS_CMD_UPLOAD_REQUEST_ID        0x0Au                         /**< ANT-FS upload request command ID. */
-#define ANTFS_CMD_ERASE_ID                 0x0Bu                         /**< ANT-FS erase request command ID. */
-#define ANTFS_CMD_UPLOAD_DATA_ID           0x0Cu                         /**< ANT-FS upload command ID. */
-
-// Responses.
-#define ANTFS_RSP_AUTHENTICATE_ID          0x84u                         /**< ANT-FS authenticate response command ID. */
-#define ANTFS_RSP_DOWNLOAD_ID              0x89u                         /**< ANT-FS download request response command ID. */
-#define ANTFS_RSP_UPLOAD_REQ_ID            0x8Au                         /**< ANT-FS upload request response command ID. */
-#define ANTFS_RSP_ERASE_ID                 0x8Bu                         /**< ANT-FS erase response command ID. */
-#define ANTFS_RSP_UPLOAD_DATA_ID           0x8Cu                         /**< ANT-FS upload data response command ID. */
-
-// Link command.
-#define TRANSPORT_CHANNEL_FREQUENCY_OFFSET 0x02u                         /**< Channel frequency field offset within link command. */
-#define TRANSPORT_MESSAGE_PERIOD_OFFSET    0x03u                         /**< Channel period field offset within link command. */
-#define HOST_ID_OFFSET_0                   0x04u                         /**< Host serial number period field LSB offset within link command. */
-#define HOST_ID_OFFSET_1                   0x05u                         /**< Host serial number period field LSB + 1 offset within link command. */
-#define HOST_ID_OFFSET_2                   0x06u                         /**< Host serial number period field LSB + 2 offset within link command. */
-#define HOST_ID_OFFSET_3                   0x07u                         /**< Host serial number period field MSB offset within link command. */
-
-// Authenticate command.
-#define COMMAND_TYPE_OFFSET                0x02u                         /**< Command type field offset within authenticate command. */
-   #define COMMAND_TYPE_PROCEED            0x00u                         /**< Command type proceed to transport in the authenticate command. */
-   #define COMMAND_TYPE_REQUEST_SERIAL     0x01u                         /**< Command type request client device serial number in the authenticate command. */
-   #define COMMAND_TYPE_REQUEST_PAIR       0x02u                         /**< Command type request pairing in the authenticate command. */
-   #define COMMAND_TYPE_REQUEST_PASSKEY    0x03u                         /**< Command type request passkey exchange in the authenticate command. */
-
-// Authenticate response.
-#define RESPONSE_TYPE_OFFSET               0x02u                         /**< Command type field offset within authenticate response command. */
-   #define AUTH_RESPONSE_N_A               0x00u                         /**< Command response type N/A (response for client serial number request). */
-   #define AUTH_RESPONSE_ACCEPT            0x01u                         /**< Command response type accept. */
-   #define AUTH_RESPONSE_REJECT            0x02u                         /**< Command response type reject. */
-
-// Authenticate command/response.
-#define AUTH_STRING_LENGTH_OFFSET          0x03u                         /**< Authenticate Command/Response authentication string length offset. */
-#define SERIAL_NUMBER_OFFSET_0             0x04u                         /**< Authenticate Command/Response client/host serial number LSB offset. */
-#define SERIAL_NUMBER_OFFSET_1             0x05u                         /**< Authenticate Command/Response client/host serial number LSB + 1 offset. */
-#define SERIAL_NUMBER_OFFSET_2             0x06u                         /**< Authenticate Command/Response client/host serial number LSB + 2 offset. */
-#define SERIAL_NUMBER_OFFSET_3             0x07u                         /**< Authenticate Command/Response client/host serial number MSB offset. */
-
-// Download/Upload/Erase commands.
-#define INITIAL_REQUEST_OFFSET             0x01u                         /**< Download/Upload/Erase command initial request command offset. */
-#define DATA_INDEX_OFFSET_LOW              0x02u                         /**< Download/Upload/Erase command offset index low. */
-#define DATA_INDEX_OFFSET_HIGH             0x03u                         /**< Download/Upload/Erase command offset index high. */
-
-#define ADDRESS_PARAMETER_OFFSET_0         0x04u                         /**< Download/Upload command parameter LSB offset. */
-#define ADDRESS_PARAMETER_OFFSET_1         0x05u                         /**< Download/Upload command parameter LSB + 1 offset. */
-#define ADDRESS_PARAMETER_OFFSET_2         0x06u                         /**< Download/Upload command parameter LSB + 2 offset. */
-#define ADDRESS_PARAMETER_OFFSET_3         0x07u                         /**< Download/Upload command parameter MSB offset. */
-#define UPLOAD_CRC_OFFSET_LOW              0x06u                         /**< Upload data CRC offset low. */
-#define UPLOAD_CRC_OFFSET_HIGH             0x07u                         /**< Upload data CRC offset high. */
-
-// Authentication type. The highest level of authentication available is included in the beacon.
-#if ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED
-   #define AUTHENTICATION_TYPE             COMMAND_TYPE_REQUEST_PASSKEY  /**< Passkey and pairing only mode set as authentication type in beacon. */
-#elif ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED
-   #define AUTHENTICATION_TYPE             COMMAND_TYPE_REQUEST_PAIR     /**< Pairing only mode set as authentication type in beacon. */
-#elif ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED
-   #define AUTHENTICATION_TYPE             COMMAND_TYPE_PROCEED          /**< Pass-through mode set as authentication type in beacon. */
-#else
-   #error "No valid auth type defined"
-#endif
-
-#define AUTHENTICATION_RETRIES             0x05u                         /**< Max number of retries for authentication responses */
-
-#define ANTFS_EVENT_QUEUE_SIZE             0x04u                         /**< ANT-FS event queue size. */
-#define SAVE_DISTANCE                       256u                         /**< Save distance required because of nRF buffer to line up data offset on retry. */
-
-// Buffer Indices.
-#define BUFFER_INDEX_MESG_SIZE             0x00u                         /**< ANT message buffer index length offset. */
-#define BUFFER_INDEX_MESG_ID               0x01u                         /**< ANT message buffer index ID offset. */
-#define BUFFER_INDEX_CHANNEL_NUM           0x02u                         /**< ANT message buffer index channel number offset. */
-#define BUFFER_INDEX_MESG_DATA             0x03u                         /**< ANT message buffer index begin of data offset. */
-#define BUFFER_INDEX_RESPONSE_CODE         0x04u                         /**< ANT message buffer index response code offset. */
-
-typedef struct
-{
-    char     friendly_name[ANTFS_FRIENDLY_NAME_MAX];                      /**< Friendly Name. */
-    bool     is_name_set;                                                 /**< Is the name set. */
-    uint32_t index;                                                       /**< Current index (for reading the friendly name). */
-    uint32_t friendly_name_size;                                          /**< Friendly name size. */
-} friendly_name_t;
-
-typedef union
-{
-    antfs_link_substate_t         link_sub_state;                         /**< Sub-state (Link layer). */
-    antfs_authenticate_substate_t auth_sub_state;                         /**< Sub-state (Authentication layer). */
-    antfs_transport_substate_t    trans_sub_state;                        /**< Sub-state (Transport layer). */
-} antfs_substate_t;
-
-typedef struct
-{
-    antfs_state_t    state;                                               /**< ANT-FS state. */
-    antfs_substate_t sub_state;                                           /**< ANT-FS sub-state. */
-} antfs_states_t;
-
-typedef struct
-{
-    antfs_event_return_t * p_queue;                                       /**< ANT-FS event queue. */
-    uint32_t head;                                                        /**< ANT-FS event queue head index. */
-    uint32_t tail;                                                        /**< ANT-FS event queue tail index. */
-} antfs_event_queue_t;
-
-static antfs_params_t              m_initial_parameters;                  /**< Initial parameters. */
-static antfs_beacon_status_byte1_t m_active_beacon_status1_field;         /**< Status 1 field in beacon. */
-static uint32_t                    m_active_beacon_frequency;             /**< Active beacon frequency. */
-static antfs_states_t              m_current_state;                       /**< Current state. */
-static friendly_name_t             m_friendly_name;                       /**< Host's friendly name. */
-static ulong_union_t               m_link_host_serial_number;             /**< Host's serial number. */
-static uint32_t                    m_link_command_in_progress;            /**< ANT-FS command in progress. */
-static uint32_t                    m_authenticate_command_type;           /**< Authenticate command type in progress. */
-static volatile uint8_t            m_burst_wait;                          /**< Polling status flag for data unlock on burst handler input. */
-static uint8_t                     m_retry;                               /**< Retry counter */
-APP_TIMER_DEF(m_timer_id);                                                /**< Timer ID used with the timer module. */
-
-#if ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED
-   static uint32_t m_passkey_index;                                       /**< Current location of Tx block (auth string). */
-#endif // ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED
-
-// Download/upload.
-static bool            m_is_data_request_pending;                         /**< Requested data pending. */
-static bool            m_is_crc_pending;                                  /**< CRC for data packets pending. */
-static ushort_union_t  m_file_index;                                      /**< File index of current upload/download. */
-static ulong_union_t   m_file_size;                                       /**< File size of current upload/download (bytes). */
-static ulong_union_t   m_max_block_size;                                  /**< Maximum number of bytes expected to be downloaded in a single burst block of data (set by host). */
-static ulong_union_t   m_link_burst_index;                                /**< Current location of Tx block (bytes). */
-static ulong_union_t   m_bytes_remaining;                                 /**< Total remaining data length (bytes). */
-static ulong_union_t   m_max_transfer_index;                              /**< Upper limit of the current Tx burst block (bytes). */
-static uint32_t        m_bytes_to_write;                                  /**< Number of bytes to write to file (upload). */
-static const uint8_t * mp_upload_data;                                    /**< Address of begin of the buffer that holds data received from upload. */
-#if ANTFS_CONFIG_UPLOAD_ENABLED
-    static ulong_union_t m_block_size;                                    /**< Number of bytes the client can receive in a single burst. */
-#endif // ANTFS_CONFIG_UPLOAD_ENABLED
-
-// CRC verification.
-static uint32_t m_saved_crc_offset;                                       /**< CRC data offset (bytes) saved at last CRC update (save point). */
-static uint32_t m_saved_buffer_crc_offset;                                /**< Data offset to track how much data has been buffered into nRF */
-static uint32_t m_temp_crc_offset;                                        /**< Temporary CRC data offset used in CRC calculation. */
-static uint16_t m_compared_crc;                                           /**< 16-bit CRC for all data packets in the block (provided by download request). */
-static uint16_t m_transfer_crc;                                           /**< 16-bit CRC for all data packets in the block (calculated by client). */
-static uint16_t m_saved_transfer_crc;                                     /**< 16-bit CRC saved at last CRC update (save point). */
-static uint16_t m_saved_buffer_crc;                                       /**< 16-bit CRC saved at last CRC update (save point) for buffering the nRF */
-
-// ANT-FS event handling.
-static antfs_event_return_t m_event_queue_buffer[ANTFS_EVENT_QUEUE_SIZE]; /**< Event queue storage. */
-static antfs_event_queue_t m_event_queue;                                 /**< Event queue. */
-
-static antfs_burst_wait_handler_t m_burst_wait_handler = NULL;            /**< Burst wait handler */
-
-
-const char * antfs_hostname_get(void)
-{
-    if (m_friendly_name.is_name_set)
-    {
-        return (m_friendly_name.friendly_name);
-    }
-
-    return NULL;
-}
-
-
-/**@brief Function for waiting for the burst transmission request to complete.
- */
-static void wait_burst_request_to_complete(void)
-{
-    while (m_burst_wait != 0)
-    {
-        if (m_burst_wait_handler != NULL)
-        {
-            m_burst_wait_handler();
-        }
-    };
-}
-
-
-/**@brief Function for stopping ANT-FS timeout, which is possibly currently running.
- */
-static void timeout_disable(void)
-{
-    m_link_command_in_progress = ANTFS_CMD_NONE;
-
-    const uint32_t err_code = app_timer_stop(m_timer_id);
-    APP_ERROR_CHECK(err_code);
-}
-
-
-/**@brief Function for transmitting a beacon.
- *
- * Transmits a beacon either using a broadcast or burst transmission mode.
- *
- * @param[in] message_type     Defines the used transmission mode.
- */
-static void beacon_transmit(uint32_t message_type)
-{
-    uint8_t beacon_status_byte2;
-
-    // Set beacon status byte 2.
-
-    if (m_link_command_in_progress == ANTFS_CMD_NONE)
-    {
-        switch (m_current_state.state)
-        {
-            case ANTFS_STATE_AUTH:
-                beacon_status_byte2 = DEVICE_STATE_AUTHENTICATE;
-                break;
-
-            case ANTFS_STATE_TRANS:
-                beacon_status_byte2 = DEVICE_STATE_TRANSPORT;
-                break;
-
-            default:
-                beacon_status_byte2 = DEVICE_STATE_LINK;
-                break;
-        }
-    }
-    else
-    {
-        beacon_status_byte2 = DEVICE_STATE_BUSY;
-    }
-
-    // Set remaining beacon fields.
-
-    uint8_t tx_buffer[BURST_PACKET_SIZE];
-
-    tx_buffer[0] = ANTFS_BEACON_ID;
-    tx_buffer[1] = m_active_beacon_status1_field.status;
-    tx_buffer[2] = beacon_status_byte2;
-    tx_buffer[3] = AUTHENTICATION_TYPE;
-
-    if ((m_current_state.state == ANTFS_STATE_AUTH) ||
-        (m_current_state.state == ANTFS_STATE_TRANS))
-    {
-        tx_buffer[4] = m_link_host_serial_number.bytes.byte0;
-        tx_buffer[5] = m_link_host_serial_number.bytes.byte1;
-        tx_buffer[6] = m_link_host_serial_number.bytes.byte2;
-        tx_buffer[7] = m_link_host_serial_number.bytes.byte3;
-    }
-    else
-    {
-        tx_buffer[4] = m_initial_parameters.beacon_device_type;
-        tx_buffer[5] = (m_initial_parameters.beacon_device_type >> 8u);
-        tx_buffer[6] = m_initial_parameters.beacon_device_manufacturing_id;
-        tx_buffer[7] = (m_initial_parameters.beacon_device_manufacturing_id >> 8u);
-    }
-
-    if (message_type == MESG_BROADCAST_DATA_ID)
-    {
-        if (sd_ant_broadcast_message_tx(ANTFS_CONFIG_CHANNEL_NUMBER, sizeof(tx_buffer), tx_buffer) != NRF_SUCCESS)
-        {
-            // @note: No implementation needed, as it is a valid and accepted use case for this call
-            // to fail. This call can fail if we are in middle of bursting.
-        }
-    }
-    else if (message_type == MESG_BURST_DATA_ID)
-    {
-        // Send as the first packet of a burst.
-        const uint32_t err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                               sizeof(tx_buffer),
-                                                               tx_buffer,
-                                                               BURST_SEGMENT_START);
-        APP_ERROR_CHECK(err_code);
-
-        wait_burst_request_to_complete();
-
-        // This is the first packet of a burst response, disable command timeout while bursting.
-        timeout_disable();
-    }
-    else
-    {
-        // This should not happen.
-        APP_ERROR_HANDLER(message_type);
-    }
-}
-
-
-/**@brief Function for transmitting a authenticate response message.
- *
- * @param[in] response_type    Authenticate response code.
- * @param[in] password_length  Length of authentication string.
- * @param[in] p_password       Authentication string transmitted.
- */
-static void authenticate_response_transmit(uint8_t response_type,
-                                           uint32_t password_length,
-                                           const uint8_t * p_password)
-{
-    ulong_union_t serial_number;
-
-    serial_number.data = m_initial_parameters.client_serial_number;
-
-    // First packet is beacon.
-    beacon_transmit(MESG_BURST_DATA_ID);
-
-    uint8_t tx_buffer[BURST_PACKET_SIZE];
-
-    tx_buffer[ANTFS_CONNECTION_TYPE_OFFSET] = ANTFS_COMMAND_ID;
-    tx_buffer[ANTFS_RESPONSE_OFFSET]        = ANTFS_RSP_AUTHENTICATE_ID;
-    tx_buffer[RESPONSE_TYPE_OFFSET]         = response_type;
-    tx_buffer[AUTH_STRING_LENGTH_OFFSET]    = password_length;
-    tx_buffer[SERIAL_NUMBER_OFFSET_0]       = serial_number.bytes.byte0;
-    tx_buffer[SERIAL_NUMBER_OFFSET_1]       = serial_number.bytes.byte1;
-    tx_buffer[SERIAL_NUMBER_OFFSET_2]       = serial_number.bytes.byte2;
-    tx_buffer[SERIAL_NUMBER_OFFSET_3]       = serial_number.bytes.byte3;
-
-    uint32_t err_code;
-    if ((m_current_state.state == ANTFS_STATE_AUTH) &&
-        (
-            (response_type != AUTH_RESPONSE_REJECT) &&
-            password_length &&
-            (password_length <= ANTFS_AUTH_STRING_MAX)
-        )
-       )
-    {
-        // Send second packet (auth response).
-        err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                sizeof(tx_buffer),
-                                                tx_buffer,
-                                                BURST_SEGMENT_CONTINUE);
-        APP_ERROR_CHECK(err_code);
-
-        wait_burst_request_to_complete();
-
-        // Round size to a multiple of 8 bytes.
-        uint8_t tx_buffer_authenticate[ANTFS_AUTH_STRING_MAX + 1u];
-
-        memset(tx_buffer_authenticate, 0, ANTFS_AUTH_STRING_MAX + 1u);
-        memcpy(tx_buffer_authenticate, p_password, password_length);
-
-        // Round up total number bytes to a multiple of 8 to be sent to burst handler.
-        if (password_length & (BURST_PACKET_SIZE - 1u))
-        {
-            password_length &= ~(BURST_PACKET_SIZE - 1u);
-            password_length += BURST_PACKET_SIZE;
-        }
-
-        // Send auth string (last packets of the burst).
-        err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                password_length,
-                                                tx_buffer_authenticate,
-                                                BURST_SEGMENT_END);
-        APP_ERROR_CHECK(err_code);
-
-        wait_burst_request_to_complete();
-
-        m_link_command_in_progress = ANTFS_RSP_AUTHENTICATE_ID;
-    }
-    else
-    {
-        // If the authorization is rejected or there is no valid password, the auth response is the
-        // last packet.
-
-        err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                sizeof(tx_buffer),
-                                                tx_buffer,
-                                                BURST_SEGMENT_END);
-        APP_ERROR_CHECK(err_code);
-
-        wait_burst_request_to_complete();
-    }
-
-    // Switch to appropiate state.
-    if (response_type == AUTH_RESPONSE_REJECT)
-    {
-        m_current_state.sub_state.auth_sub_state = ANTFS_AUTH_SUBSTATE_REJECT;
-    }
-    else if (response_type == AUTH_RESPONSE_ACCEPT)
-    {
-        m_current_state.sub_state.auth_sub_state = ANTFS_AUTH_SUBSTATE_ACCEPT;
-    }
-    else
-    {
-        // No implementation needed.
-    }
-}
-
-
-bool antfs_pairing_resp_transmit(bool accept)
-{
-#if ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED
-    // This function should only be called when ANT-FS is in PAIRING mode.
-    if ((m_current_state.state != ANTFS_STATE_AUTH) ||
-        (m_current_state.sub_state.auth_sub_state != ANTFS_AUTH_SUBSTATE_PAIR))
-    {
-        return false;
-    }
-
-    m_link_command_in_progress = ANTFS_CMD_AUTHENTICATE_ID;
-
-    if (accept)
-    {
-        // Accept request and send passkey if authentication passed.
-        authenticate_response_transmit(AUTH_RESPONSE_ACCEPT,
-                                       ANTFS_PASSKEY_SIZE,
-                                       m_initial_parameters.p_pass_key);
-    }
-    else
-    {
-        // Reject authentication request.
-        authenticate_response_transmit(AUTH_RESPONSE_REJECT, 0, NULL);
-    }
-
-    return true;
-#else
-    return false;
-#endif // ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED
-}
-
-
-/**@brief Function for adding an ANT-FS event to the event queue.
- *
- * @param[in] event_code       The event to be added.
- */
-static void event_queue_write(antfs_event_t event_code)
-{
-    antfs_event_return_t * p_event = NULL;
-#if ANTFS_CONFIG_DEBUG_LED_ENABLED
-    uint32_t err_code;
-#endif // ANTFS_CONFIG_DEBUG_LED_ENABLED
-
-    // Check if there is room in the queue for a new event.
-    if (((m_event_queue.head + 1u) & (ANTFS_EVENT_QUEUE_SIZE - 1u)) != m_event_queue.tail)
-    {
-        p_event = &(m_event_queue.p_queue[m_event_queue.head]);
-    }
-
-    if (p_event != NULL)
-    {
-        // Initialize event parameters.
-        p_event->event = event_code;
-
-        // Set parameters depending on event type.
-        switch (event_code)
-        {
-            case ANTFS_EVENT_ERASE_REQUEST:
-                p_event->file_index = m_file_index.data;
-                p_event->offset     = 0;
-                p_event->bytes      = 0;
-                p_event->crc        = 0;
-                break;
-
-            case ANTFS_EVENT_DOWNLOAD_REQUEST:
-                p_event->file_index = m_file_index.data;
-                // Requested offset for the download.
-                p_event->offset     = m_link_burst_index.data;
-                p_event->bytes      = 0;
-                p_event->crc        = 0;
-                break;
-
-            case ANTFS_EVENT_DOWNLOAD_REQUEST_DATA:
-                p_event->file_index = m_file_index.data;
-                // Current offset.
-                p_event->offset     = m_link_burst_index.data;
-
-                if (m_bytes_remaining.data > (ANTFS_BURST_BLOCK_SIZE * BURST_PACKET_SIZE))
-                {
-                    // If remaining bytes > burst block size then grab one block at a time.
-                    p_event->bytes = ANTFS_BURST_BLOCK_SIZE * BURST_PACKET_SIZE;
-                }
-                else
-                {
-                    p_event->bytes = m_bytes_remaining.data;
-                }
-
-                p_event->crc = 0;
-                break;
-
-            case ANTFS_EVENT_UPLOAD_REQUEST:
-                p_event->file_index = m_file_index.data;
-                // Requested offset for the upload.
-                p_event->offset     = m_link_burst_index.data;
-                // Upper limit of the download (offset + remaining bytes).
-                p_event->bytes      = m_max_transfer_index.data;
-                // CRC Seed (from last save point if resuming).
-                p_event->crc        = m_transfer_crc;
-                break;
-
-            case ANTFS_EVENT_UPLOAD_DATA:
-                p_event->file_index = m_file_index.data;
-                // Current offset.
-                p_event->offset     = m_link_burst_index.data;
-                // Current CRC.
-                p_event->crc        = m_transfer_crc;
-                // Number of bytes to write.
-                p_event->bytes      = m_bytes_to_write;
-                // Upload to appication data buffer.
-                memcpy(p_event->data, mp_upload_data, m_bytes_to_write);
-                break;
-
-            case ANTFS_EVENT_PAIRING_REQUEST:
-#if ANTFS_CONFIG_DEBUG_LED_ENABLED
-                err_code = bsp_indication_set(BSP_INDICATE_BONDING);
-                APP_ERROR_CHECK(err_code);
-#endif // ANTFS_CONFIG_DEBUG_LED_ENABLED
-                break;
-
-            default:
-                // No parameters need to be set.
-
-                p_event->file_index = 0;
-                p_event->offset     = 0;
-                p_event->bytes      = 0;
-                p_event->crc        = 0;
-                break;
-        }
-
-        // Put the event in the queue.
-        m_event_queue.head = ((m_event_queue.head + 1u) & (ANTFS_EVENT_QUEUE_SIZE - 1u));
-    }
-    else
-    {
-        // No free space left in the queue.
-        APP_ERROR_HANDLER(0);
-    }
-}
-
-
-/**@brief Function for transmitting download request response message.
- *
- * @param[in] response         Download response code.
- */
-static void download_request_response_transmit(uint8_t response)
-{
-    // First burst packet is beacon.
-    beacon_transmit(MESG_BURST_DATA_ID);
-
-    uint8_t tx_buffer[BURST_PACKET_SIZE];
-
-    // Next send the first part of the download response.
-    tx_buffer[0] = ANTFS_COMMAND_ID;
-    tx_buffer[1] = ANTFS_RSP_DOWNLOAD_ID;
-    tx_buffer[2] = response;
-    tx_buffer[3] = 0;
-    // Total number of bytes remaining in the data block.
-    tx_buffer[4] = m_bytes_remaining.bytes.byte0;
-    tx_buffer[5] = m_bytes_remaining.bytes.byte1;
-    tx_buffer[6] = m_bytes_remaining.bytes.byte2;
-    tx_buffer[7] = m_bytes_remaining.bytes.byte3;
-
-    uint32_t err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                     sizeof(tx_buffer),
-                                                     tx_buffer,
-                                                     BURST_SEGMENT_CONTINUE);
-    APP_ERROR_CHECK(err_code);
-
-    wait_burst_request_to_complete();
-
-    // Second part of the download response.
-
-    // The offset the data will start from in this block.
-    tx_buffer[0] = m_link_burst_index.bytes.byte0;
-    tx_buffer[1] = m_link_burst_index.bytes.byte1;
-    tx_buffer[2] = m_link_burst_index.bytes.byte2;
-    tx_buffer[3] = m_link_burst_index.bytes.byte3;
-    // The file size in the client device.
-    tx_buffer[4] = m_file_size.bytes.byte0;
-    tx_buffer[5] = m_file_size.bytes.byte1;
-    tx_buffer[6] = m_file_size.bytes.byte2;
-    tx_buffer[7] = m_file_size.bytes.byte3;
-
-    if (response || (m_bytes_remaining.data == 0))
-    {
-        // If the download was rejected or there is no data to send.
-
-        // Set response to end since we're not downloading any data.
-        err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                sizeof(tx_buffer),
-                                                tx_buffer,
-                                                BURST_SEGMENT_END);
-        APP_ERROR_CHECK(err_code);
-
-        wait_burst_request_to_complete();
-    }
-    else
-    {
-        // Response will continue (data packets + CRC footer to follow).
-        err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                sizeof(tx_buffer),
-                                                tx_buffer,
-                                                BURST_SEGMENT_CONTINUE);
-        APP_ERROR_CHECK(err_code);
-
-        wait_burst_request_to_complete();
-    }
-
-    m_link_command_in_progress = ANTFS_CMD_DOWNLOAD_ID;
-
-    if (response == 0)
-    {
-        // If we are going to download (response OK), enter the downloading substate.
-        m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_DOWNLOADING;
-        event_queue_write(ANTFS_EVENT_DOWNLOAD_START);
-    }
-    else
-    {
-        // Download rejected.
-        event_queue_write(ANTFS_EVENT_DOWNLOAD_FAIL);
-    }
-}
-
-
-void antfs_download_req_resp_prepare(uint8_t response,
-                                     const antfs_request_info_t * const p_request_info)
-{
-    // This function should only be called after receiving a download request.
-    APP_ERROR_CHECK_BOOL((m_current_state.state == ANTFS_STATE_TRANS) &&
-                         (m_link_command_in_progress == ANTFS_CMD_DOWNLOAD_ID));
-
-    if (response == 0)
-    {
-        // Download request OK.
-
-        // File size of the requested download.
-        m_file_size.data = p_request_info->file_size.data;
-
-        if (m_link_burst_index.data > m_file_size.data)
-        {
-            // Offset should not exceed file size.
-            m_link_burst_index.data = m_file_size.data;
-        }
-
-        // If the host is not limiting download size or the file size does not exceed the host's
-        // download size limit.
-        if ((m_max_block_size.data == 0) || (m_file_size.data < m_max_block_size.data))
-        {
-            //  Number of bytes remaining to be downloaded in this block is the file size.
-            m_bytes_remaining.data = m_file_size.data;
-        }
-
-        if ((m_file_size.data - m_link_burst_index.data) < m_bytes_remaining.data)
-        {
-            // Calculate number of remaining bytes in this block based on the offset.
-            m_bytes_remaining.data = m_file_size.data - m_link_burst_index.data;
-        }
-
-        // If the application is limiting the Tx block size.
-        if (m_bytes_remaining.data > p_request_info->max_burst_block_size.data)
-        {
-            // Number of remaining bytes in this block is the application defined block size.
-            m_bytes_remaining.data = p_request_info->max_burst_block_size.data;
-        }
-
-        // Find upper limit of the burst Tx.
-        m_max_transfer_index.data = m_link_burst_index.data + m_bytes_remaining.data;
-
-        if (m_saved_crc_offset == ANTFS_MAX_FILE_SIZE)
-        {
-            // CRC checking was set as invalid. An invalid download was requested, so reject it.
-            response = RESPONSE_INVALID_OPERATION;
-        }
-    }
-
-    if ((response != 0) || (m_file_size.data == 0))
-    {
-        // Send the response right away if the download request was rejected or there is no data to
-        // send.
-        download_request_response_transmit(response);
-    }
-    else
-    {
-        // Proceed to download data.
-        if (m_link_burst_index.data != m_saved_crc_offset)
-        {
-            uint32_t temp;
-
-            // If requesting to resume exactly where we left off, we can start from the same block.
-            if (m_link_burst_index.data == m_temp_crc_offset)
-            {
-                // Move last save point to end of last block sent.
-                m_saved_crc_offset   = m_link_burst_index.data;
-                m_saved_transfer_crc = m_transfer_crc;
-            }
-
-            // To resume the download, request a block of data starting from the last save point.
-            // Update the remaining number of bytes per the last save point.
-            m_bytes_remaining.data += (m_link_burst_index.data - m_saved_crc_offset);
-
-            // Swap the current burst Tx index with the saved CRC index, to make sure we do not
-            // start updating the CRC until we get to the requested index.
-            temp                    = m_link_burst_index.data;
-            m_link_burst_index.data = m_saved_crc_offset;
-            m_saved_crc_offset      = temp;
-
-            // Set CRC to previous save point, to check the CRC provided by the host.
-            m_transfer_crc = m_saved_transfer_crc;
-        }
-
-        m_temp_crc_offset = m_saved_crc_offset;
-
-        m_is_data_request_pending = true;
-
-        // Request data from application.
-        event_queue_write(ANTFS_EVENT_DOWNLOAD_REQUEST_DATA);
-
-        m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_VERIFY_CRC;
-    }
-}
-
-
-uint32_t antfs_input_data_download(uint16_t index,
-                                   uint32_t offset,
-                                   uint32_t num_bytes,
-                                   const uint8_t * const p_message)
-{
-    // Verify that this is the requested data.
-    APP_ERROR_CHECK_BOOL((offset == m_link_burst_index.data) && (index == m_file_index.data));
-
-    // If file offset is greater than the upper limit, this is not data we need.
-    APP_ERROR_CHECK_BOOL(offset <= m_max_transfer_index.data);
-
-    if ((m_current_state.state == ANTFS_STATE_TRANS) &&
-        (
-            (m_current_state.sub_state.trans_sub_state == ANTFS_TRANS_SUBSTATE_VERIFY_CRC) ||
-            // Only send data if we were processing a download request.
-            (m_current_state.sub_state.trans_sub_state == ANTFS_TRANS_SUBSTATE_DOWNLOADING)
-        )
-       )
-    {
-        uint32_t block_offset = 0;
-
-        if (m_current_state.sub_state.trans_sub_state == ANTFS_TRANS_SUBSTATE_VERIFY_CRC)
-        {
-            // Make sure download_request_response_transmit defaults to RESPONSE_INVALID_CRC.
-            uint32_t response = RESPONSE_MESSAGE_OK;
-
-            // Check CRC.
-            if (m_link_burst_index.data == m_saved_crc_offset)
-            {
-                // If indexes match, we can compare CRC directly.
-                if (m_transfer_crc != m_compared_crc)
-                {
-                    response = RESPONSE_INVALID_CRC;
-                }
-                else
-                {
-                    // Set up the save point
-                    m_temp_crc_offset = m_link_burst_index.data; // Reset save point counter
-                    m_saved_crc_offset = m_link_burst_index.data;
-                    m_saved_buffer_crc_offset = m_link_burst_index.data;
-
-                    // Set up the CRC save points
-                    m_saved_transfer_crc = m_compared_crc;
-                    m_saved_buffer_crc = m_compared_crc;
-                    m_is_crc_pending     = true;
-                }
-                // Start bursting beacon and the download response (3 burst packets).
-                download_request_response_transmit(response);
-            }
-            // If the data is in this block, advance to the requested offset
-            else if ((m_link_burst_index.data < m_saved_crc_offset) &&
-                     ((m_saved_crc_offset - m_link_burst_index.data) < num_bytes))
-            {
-                // Update the offset within this block for the requested transmission.
-                block_offset = m_saved_crc_offset - m_link_burst_index.data;
-                // Update the number of bytes that will actually be transmitted.
-                num_bytes   -= block_offset;
-
-                // Update CRC calculation up to requested index.
-                m_transfer_crc          = crc_crc16_update(m_transfer_crc, p_message, block_offset);
-                // Update the remaining number of bytes.
-                m_bytes_remaining.data -= block_offset;
-
-                // Check CRC
-                if (m_transfer_crc != m_compared_crc)
-                {
-                    response = RESPONSE_INVALID_CRC;
-                }
-                else
-                {
-                    // Move index back to point where transmission will resume.
-                    m_link_burst_index.data = m_saved_crc_offset;
-
-                    // Set up the save point
-                    m_temp_crc_offset = m_link_burst_index.data; // Reset save point counter
-                    m_saved_buffer_crc_offset = m_link_burst_index.data;
-
-                    // Set up the CRC save points
-                    m_saved_transfer_crc = m_compared_crc;
-                    m_saved_buffer_crc = m_compared_crc;
-
-                    m_is_crc_pending = true;
-                }
-                download_request_response_transmit(response);
-            }
-            // Data index has gone too far and it is not possible to check CRC, fail and let host retry
-            else if (m_link_burst_index.data > m_saved_crc_offset)
-            {
-                response = RESPONSE_INVALID_CRC;
-                download_request_response_transmit(response);
-            }
-            // Keep getting data and recalculate the CRC until the indexes match
-            else
-            {
-                m_is_data_request_pending = false;
-
-                // Update the current burst index and bytes remaining
-                m_link_burst_index.data += num_bytes;
-                m_bytes_remaining.data -= num_bytes;
-
-                // Update CRC
-                m_transfer_crc = crc_crc16_update(m_transfer_crc, p_message, num_bytes);
-
-                // Request more data.
-                event_queue_write(ANTFS_EVENT_DOWNLOAD_REQUEST_DATA);
-            }
-        }
-
-        // Append data.
-        if (m_current_state.sub_state.trans_sub_state == ANTFS_TRANS_SUBSTATE_DOWNLOADING)
-        {
-            uint32_t num_of_bytes_to_burst = num_bytes;
-
-            if (num_of_bytes_to_burst & (BURST_PACKET_SIZE - 1u))
-            {
-                // Round up total number bytes to a multiple of BURST_PACKET_SIZE to be sent to
-                // burst handler.
-                num_of_bytes_to_burst &= ~(BURST_PACKET_SIZE - 1u);
-                num_of_bytes_to_burst += BURST_PACKET_SIZE;
-            }
-
-            uint32_t err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                             num_of_bytes_to_burst,
-                                                             (uint8_t*)&(p_message[block_offset]),
-                                                             BURST_SEGMENT_CONTINUE);
-            if (err_code != NRF_ANT_ERROR_TRANSFER_SEQUENCE_NUMBER_ERROR)
-            {
-                // If burst failed before we are able to catch it, we will get a TRANSFER_SEQUENCE_NUMBER_ERROR
-                // The message processing will send client back to correct state
-                APP_ERROR_CHECK(err_code);
-            }
-
-            wait_burst_request_to_complete();
-
-            // Update current burst index.
-            m_link_burst_index.data += num_bytes;
-            // Update remaining bytes.
-            m_bytes_remaining.data  -= num_bytes;
-
-            m_is_data_request_pending = false;
-
-            m_transfer_crc = crc_crc16_update(m_transfer_crc,
-                                              &(p_message[block_offset]),
-                                              num_bytes);
-
-            if ((m_link_burst_index.data - m_temp_crc_offset) > SAVE_DISTANCE)
-            {
-                // Set CRC save point
-                m_saved_transfer_crc = m_saved_buffer_crc;  // Set CRC at buffer save point (will always be one behind to account for buffering)
-                m_saved_buffer_crc = m_transfer_crc;        // Set CRC at save point
-
-                // Set offset save point
-                m_saved_crc_offset = m_saved_buffer_crc_offset;     // Set offset at buffer save point (will always be one behind to account for buffering)
-                m_saved_buffer_crc_offset = m_link_burst_index.data;    // Set buffer offset to current data offset
-
-                // Reset save counter offset
-                m_temp_crc_offset = m_link_burst_index.data;    // Set to current location; next save point will take place after SAVE_DISTANCE bytes
-            }
-
-            if (!m_is_data_request_pending && (m_link_burst_index.data < m_max_transfer_index.data))
-            {
-                // If we have not finished the download.
-
-                // Request more data.
-                event_queue_write(ANTFS_EVENT_DOWNLOAD_REQUEST_DATA);
-
-                m_is_data_request_pending = true;
-            }
-            else if (m_link_burst_index.data >= m_max_transfer_index.data && m_is_crc_pending)
-            {
-                // We are done, send CRC footer.
-
-                uint8_t tx_buffer[BURST_PACKET_SIZE];
-
-                tx_buffer[0] = 0;
-                tx_buffer[1] = 0;
-                tx_buffer[2] = 0;
-                tx_buffer[3] = 0;
-                tx_buffer[4] = 0;
-                tx_buffer[5] = 0;
-                tx_buffer[6] = (uint8_t)m_transfer_crc;
-                tx_buffer[7] = (uint8_t)(m_transfer_crc >> 8u);
-
-                err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                        sizeof(tx_buffer),
-                                                        tx_buffer,
-                                                        BURST_SEGMENT_END);
-                if (err_code != NRF_ANT_ERROR_TRANSFER_SEQUENCE_NUMBER_ERROR)
-                {
-                    // If burst failed before we are able to catch it, we will get a TRANSFER_SEQUENCE_NUMBER_ERROR
-                    // The message processing will send client back to correct state
-                    APP_ERROR_CHECK(err_code);
-                }
-
-                wait_burst_request_to_complete();
-
-                m_is_crc_pending          = false;
-                m_max_transfer_index.data = 0;
-            }
-
-            // Return the number of bytes we accepted.
-            return num_bytes;
-        }
-    }
-
-    // No bytes were accepted.
-    return 0;
-}
-
-
-bool antfs_upload_req_resp_transmit(uint8_t response,
-                                    const antfs_request_info_t * const p_request_info)
-{
-#if ANTFS_CONFIG_UPLOAD_ENABLED
-    if (m_current_state.state != ANTFS_STATE_TRANS ||
-        // Only send the response if we were processing an upload request.
-        (m_link_command_in_progress != ANTFS_CMD_UPLOAD_REQUEST_ID))
-    {
-        return false;
-    }
-
-    // If the application is sending a response for a different file than requested, the upload
-    // will fail.
-    if (p_request_info->file_index.data != m_file_index.data)
-    {
-        event_queue_write(ANTFS_EVENT_UPLOAD_FAIL);
-
-        return false;
-    }
-
-    ulong_union_t max_mem_size;
-    // Set maximum number of bytes that can be written to the file.
-    max_mem_size.data = p_request_info->max_file_size;
-
-    if (p_request_info->max_burst_block_size.data != 0)
-    {
-        // If the client is limiting the block size set the block size requested by the client.
-        m_block_size.data = p_request_info->max_burst_block_size.data;
-    }
-    else
-    {
-        // Try to get the entire file in a single block.
-        m_block_size.data = max_mem_size.data;
-    }
-
-    if (response == 0)
-    {
-        if (m_max_transfer_index.data > max_mem_size.data)
-        {
-            // Not enough space to write file, reject download.
-            response = RESPONSE_MESSAGE_NOT_ENOUGH_SPACE;
-        }
-    }
-
-    // Get last valid CRC and last valid offset.
-    m_transfer_crc          = p_request_info->file_crc;
-    m_link_burst_index.data = p_request_info->file_size.data;
-
-    // First packet to transmit is the beacon.
-    beacon_transmit(MESG_BURST_DATA_ID);
-
-    // Second packet.
-
-    uint8_t tx_buffer[BURST_PACKET_SIZE];
-
-    tx_buffer[0] = ANTFS_COMMAND_ID;
-    tx_buffer[1] = ANTFS_RSP_UPLOAD_REQ_ID;
-    tx_buffer[2] = response;
-    tx_buffer[3] = 0;
-    // Last valid data offset written to the file.
-    tx_buffer[4] = m_link_burst_index.bytes.byte0;
-    tx_buffer[5] = m_link_burst_index.bytes.byte1;
-    tx_buffer[6] = m_link_burst_index.bytes.byte2;
-    tx_buffer[7] = m_link_burst_index.bytes.byte3;
-
-
-    uint32_t err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                     sizeof(tx_buffer),
-                                                     tx_buffer,
-                                                     BURST_SEGMENT_CONTINUE);
-    APP_ERROR_CHECK(err_code);
-
-    wait_burst_request_to_complete();
-
-    // Third packet.
-
-    // Maximum number of bytes that can be written to the file.
-    tx_buffer[0] = max_mem_size.bytes.byte0;
-    tx_buffer[1] = max_mem_size.bytes.byte1;
-    tx_buffer[2] = max_mem_size.bytes.byte2;
-    tx_buffer[3] = max_mem_size.bytes.byte3;
-    // Maximum upload block size.
-    tx_buffer[4] = m_block_size.bytes.byte0;
-    tx_buffer[5] = m_block_size.bytes.byte1;
-    tx_buffer[6] = m_block_size.bytes.byte2;
-    tx_buffer[7] = m_block_size.bytes.byte3;
-
-    err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                            sizeof(tx_buffer),
-                                            tx_buffer,
-                                            BURST_SEGMENT_CONTINUE);
-    APP_ERROR_CHECK(err_code);
-
-    wait_burst_request_to_complete();
-
-    // Fourth packet.
-
-    tx_buffer[0] = 0;
-    tx_buffer[1] = 0;
-    tx_buffer[2] = 0;
-    tx_buffer[3] = 0;
-    tx_buffer[4] = 0;
-    tx_buffer[5] = 0;
-    // Value of CRC at last data offset.
-    tx_buffer[6] = (uint8_t) m_transfer_crc;
-    tx_buffer[7] = (uint8_t)(m_transfer_crc >> 8);
-
-    err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                            sizeof(tx_buffer),
-                                            tx_buffer,
-                                            BURST_SEGMENT_END);
-    APP_ERROR_CHECK(err_code);
-
-    wait_burst_request_to_complete();
-
-    m_link_command_in_progress = ANTFS_CMD_UPLOAD_REQUEST_ID;
-
-    if (response != 0)
-    {
-        // Failed upload request. Reset max transfer index to 0 (do not accept any data if the host
-        // sends it anyway).
-        m_max_transfer_index.data = 0;
-    }
-    else
-    {
-        // Wait for upload data request.
-        m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_UPLOAD_WAIT_FOR_DATA;
-    }
-
-    return true;
-#else
-    return false;
-#endif  // ANTFS_CONFIG_UPLOAD_ENABLED
-}
-
-
-bool antfs_upload_data_resp_transmit(bool data_upload_success)
-{
-#if ANTFS_CONFIG_UPLOAD_ENABLED
-    // Should be in TRANSPORT layer to send this response.
-    if (m_current_state.state != ANTFS_STATE_TRANS)
-    {
-        return false;
-    }
-
-    uint8_t tx_buffer[BURST_PACKET_SIZE];
-
-    // Response.
-    tx_buffer[0] = ANTFS_COMMAND_ID;
-    tx_buffer[1] = ANTFS_RSP_UPLOAD_DATA_ID;
-    tx_buffer[2] = (data_upload_success) ? RESPONSE_MESSAGE_OK : RESPONSE_MESSAGE_FAIL;
-    tx_buffer[3] = 0;
-    tx_buffer[4] = 0;
-    tx_buffer[5] = 0;
-    tx_buffer[6] = 0;
-    tx_buffer[7] = 0;
-
-    // First packet is beacon.
-    beacon_transmit(MESG_BURST_DATA_ID);
-
-    // Send last packet.
-    uint32_t err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                     sizeof(tx_buffer),
-                                                     tx_buffer,
-                                                     BURST_SEGMENT_END);
-    APP_ERROR_CHECK(err_code);
-
-    wait_burst_request_to_complete();
-
-    m_link_command_in_progress = ANTFS_CMD_UPLOAD_REQUEST_ID;
-
-    // Reset maximum index.
-    m_max_transfer_index.data = 0;
-
-    return true;
-#else
-    return false;
-#endif  // ANTFS_CONFIG_UPLOAD_ENABLED
-}
-
-
-void antfs_erase_req_resp_transmit(uint8_t response)
-{
-    // This function should only be called after receiving an erase request.
-    APP_ERROR_CHECK_BOOL((m_current_state.state == ANTFS_STATE_TRANS) &&
-                         (m_link_command_in_progress == ANTFS_CMD_ERASE_ID));
-
-    beacon_transmit(MESG_BURST_DATA_ID);
-
-    uint8_t tx_buffer[BURST_PACKET_SIZE];
-
-    // Erase response.
-    tx_buffer[0] = ANTFS_COMMAND_ID;
-    tx_buffer[1] = ANTFS_RSP_ERASE_ID;
-    tx_buffer[2] = response;
-    tx_buffer[3] = 0;
-    tx_buffer[4] = 0;
-    tx_buffer[5] = 0;
-    tx_buffer[6] = 0;
-    tx_buffer[7] = 0;
-
-    uint32_t err_code = sd_ant_burst_handler_request(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                     sizeof(tx_buffer),
-                                                     tx_buffer,
-                                                     BURST_SEGMENT_END);
-    APP_ERROR_CHECK(err_code);
-
-    wait_burst_request_to_complete();
-}
-
-
-bool antfs_event_extract(antfs_event_return_t * const p_event)
-{
-    bool return_value = false;
-
-    if (m_event_queue.head != m_event_queue.tail)
-    {
-        // Pending events exist. Copy event parameters into return event.
-        p_event->event      = m_event_queue.p_queue[m_event_queue.tail].event;
-        p_event->file_index = m_event_queue.p_queue[m_event_queue.tail].file_index;
-        p_event->offset     = m_event_queue.p_queue[m_event_queue.tail].offset;
-        p_event->bytes      = m_event_queue.p_queue[m_event_queue.tail].bytes;
-        p_event->crc        = m_event_queue.p_queue[m_event_queue.tail].crc;
-        memcpy(p_event->data,
-               m_event_queue.p_queue[m_event_queue.tail].data,
-               sizeof(p_event->data));
-
-        // Release the event queue.
-        m_event_queue.tail = ((m_event_queue.tail + 1u) & (ANTFS_EVENT_QUEUE_SIZE - 1u));
-
-        return_value = true;
-    }
-
-    return return_value;
-}
-
-
-/**@brief Function for setting the channel period.
- *
- * Sets the channel period. The only allowed frequencies are 0.5, 1, 2, 4 and 8 Hz.
- *
- * @param[in] link_period      Link period for the beacon transmission.
- */
-static void channel_period_set(uint32_t link_period)
-{
-    uint32_t period;
-
-    switch (link_period)
-    {
-        default:
-            // Shouldn't happen, but just in case default to 0,5Hz.
-        case BEACON_PERIOD_0_5_HZ:
-            period = 65535u;
-            break;
-
-        case BEACON_PERIOD_1_HZ:
-            period = 32768u;
-            break;
-
-        case BEACON_PERIOD_2_HZ:
-            period = 16384u;
-            break;
-
-        case BEACON_PERIOD_4_HZ:
-            period = 8192u;
-            break;
-
-        case BEACON_PERIOD_8_HZ:
-            period = 4096u;
-            break;
-    }
-
-    const uint32_t err_code = sd_ant_channel_period_set(ANTFS_CONFIG_CHANNEL_NUMBER, period);
-    APP_ERROR_CHECK(err_code);
-}
-
-
-/**@brief Function for starting ANT-FS timeout.
- *
- * @param[in] timeout_in_secs  Timeout requested in unit of seconds.
- */
-static void timeout_start(uint32_t timeout_in_secs)
-{
-    uint32_t err_code = app_timer_stop(m_timer_id);
-    APP_ERROR_CHECK(err_code);
-
-    err_code = app_timer_start(m_timer_id,
-                               APP_TIMER_TICKS((uint32_t)(timeout_in_secs * 1000u)),
-                               NULL);
-    APP_ERROR_CHECK(err_code);
-}
-
-
-/**@brief Function for switching to authentication layer.
- */
-static void authenticate_layer_transit(void)
-{
-    if (m_current_state.state != ANTFS_STATE_OFF)
-    {
-        m_current_state.state                    = ANTFS_STATE_AUTH;
-        m_current_state.sub_state.auth_sub_state = ANTFS_AUTH_SUBSTATE_NONE;
-        m_link_command_in_progress               = ANTFS_CMD_NONE;
-
-        timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-
-        uint32_t err_code = sd_ant_channel_radio_freq_set(ANTFS_CONFIG_CHANNEL_NUMBER, m_active_beacon_frequency);
-        APP_ERROR_CHECK(err_code);
-
-        event_queue_write(ANTFS_EVENT_AUTH);
-    }
-}
-
-
-/**@brief Function for decoding an ANT-FS command received at the link layer.
- *
- * @param[in] p_command_buffer The ANT-FS command buffer.
- */
-static void link_layer_cmd_decode(const uint8_t * p_command_buffer)
-{
-    if (p_command_buffer[ANTFS_CONNECTION_TYPE_OFFSET] != ANTFS_COMMAND_ID)
-    {
-        return;
-    }
-
-    switch (p_command_buffer[ANTFS_COMMAND_OFFSET])
-    {
-        case ANTFS_CMD_LINK_ID:
-            // Channel frequency.
-            m_active_beacon_frequency                            =
-                p_command_buffer[TRANSPORT_CHANNEL_FREQUENCY_OFFSET];
-            // Channel message period.
-            m_active_beacon_status1_field.parameters.link_period =
-                p_command_buffer[TRANSPORT_MESSAGE_PERIOD_OFFSET];
-            // Host serial Number.
-            m_link_host_serial_number.bytes.byte0                =
-                p_command_buffer[HOST_ID_OFFSET_0];
-            m_link_host_serial_number.bytes.byte1                =
-                p_command_buffer[HOST_ID_OFFSET_1];
-            m_link_host_serial_number.bytes.byte2                =
-                p_command_buffer[HOST_ID_OFFSET_2];
-            m_link_host_serial_number.bytes.byte3                =
-                p_command_buffer[HOST_ID_OFFSET_3];
-
-            // Move to the channel period issued by the host.
-            channel_period_set(m_active_beacon_status1_field.parameters.link_period);
-
-            authenticate_layer_transit();
-            break;
-
-        default:
-            break;
-    }
-}
-
-
-/**@brief Function for switching to link layer.
- */
-static void link_layer_transit(void)
-{
-    if (m_current_state.state != ANTFS_STATE_OFF)
-    {
-        uint32_t err_code;
-#if ANTFS_CONFIG_DEBUG_LED_ENABLED
-        err_code = bsp_indication_set(BSP_INDICATE_IDLE);
-        APP_ERROR_CHECK(err_code);
-#endif // ANTFS_CONFIG_DEBUG_LED_ENABLED
-
-        m_current_state.state                    = ANTFS_STATE_LINK;
-        m_current_state.sub_state.link_sub_state = ANTFS_LINK_SUBSTATE_NONE;
-        m_link_command_in_progress               = ANTFS_CMD_NONE;
-        m_active_beacon_status1_field            = m_initial_parameters.beacon_status_byte1;
-        m_active_beacon_frequency                = m_initial_parameters.beacon_frequency;
-
-        timeout_disable();
-
-        err_code = sd_ant_channel_radio_freq_set(ANTFS_CONFIG_CHANNEL_NUMBER, m_active_beacon_frequency);
-        APP_ERROR_CHECK(err_code);
-
-        event_queue_write(ANTFS_EVENT_LINK);
-    }
-}
-
-
-/**@brief Function for decoding an ANT-FS command received at the authenticate layer.
- *
- * @param[in] control_byte     The command control byte.
- * @param[in] p_command_buffer The ANT-FS command buffer.
- */
-static void authenticate_layer_cmd_decode(uint8_t control_byte,
-                                          const uint8_t * p_command_buffer)
-{
-    // @note: Response variable must have a static storage allocation as it keeps track of the
-    // passkey authentication progress between multiple burst packets.
-#if ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED
-    static uint32_t response;
-#endif // ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED
-
-    if ((control_byte & ~SEQUENCE_LAST_MESSAGE) == 0 && m_link_command_in_progress != ANTFS_CMD_NONE)
-    {
-        // This is something new, and we're busy processing something already, so don't respond
-        return;
-    }
-
-    if (p_command_buffer[ANTFS_CONNECTION_TYPE_OFFSET] == ANTFS_COMMAND_ID &&
-        m_link_command_in_progress == ANTFS_CMD_NONE)
-    {
-        if (p_command_buffer[ANTFS_COMMAND_OFFSET] == ANTFS_CMD_AUTHENTICATE_ID)
-        {
-            // Make sure it is the correct host
-            if (m_link_host_serial_number.bytes.byte0 != p_command_buffer[HOST_ID_OFFSET_0] ||
-               m_link_host_serial_number.bytes.byte1 != p_command_buffer[HOST_ID_OFFSET_1] ||
-               m_link_host_serial_number.bytes.byte2 != p_command_buffer[HOST_ID_OFFSET_2] ||
-               m_link_host_serial_number.bytes.byte3 != p_command_buffer[HOST_ID_OFFSET_3])
-                return;
-
-            m_link_command_in_progress  = ANTFS_CMD_AUTHENTICATE_ID;
-            m_authenticate_command_type = p_command_buffer[COMMAND_TYPE_OFFSET];
-            m_retry = AUTHENTICATION_RETRIES;
-        }
-    }
-
-    if (m_link_command_in_progress == ANTFS_CMD_AUTHENTICATE_ID)
-    {
-        switch (m_authenticate_command_type)
-        {
-            case COMMAND_TYPE_REQUEST_SERIAL:
-                if (control_byte & SEQUENCE_LAST_MESSAGE)
-                {
-                    // Don't do anything before the burst completes (last burst message received).
-                    timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-                    authenticate_response_transmit(AUTH_RESPONSE_N_A,
-                                                   ANTFS_REMOTE_FRIENDLY_NAME_MAX,
-                                                   // Send device friendly name if it exists.
-                                                   m_initial_parameters.p_remote_friendly_name);
-                }
-                break;
-
-#if ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED
-            case COMMAND_TYPE_PROCEED:
-                if (control_byte & SEQUENCE_LAST_MESSAGE)
-                {
-                    // Don't do anything before the burst completes (last burst message received).
-                    timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-                    // Proceed directly to transport layer (no authentication required).
-                    authenticate_response_transmit(AUTH_RESPONSE_ACCEPT, 0, NULL);
-                }
-                break;
-
-#endif // ANTFS_CONFIG_AUTH_TYPE_PASSTHROUGH_ENABLED
-#if ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED
-            case COMMAND_TYPE_REQUEST_PAIR:
-                if ((control_byte & SEQUENCE_NUMBER_ROLLOVER) == 0)
-                {
-                    // First burst packet.
-
-                    // Friendly name length.
-                    m_friendly_name.friendly_name_size =
-                        p_command_buffer[AUTH_STRING_LENGTH_OFFSET];
-
-                    if (m_friendly_name.friendly_name_size > 0)
-                    {
-                        if (m_friendly_name.friendly_name_size > ANTFS_FRIENDLY_NAME_MAX)
-                        {
-                            m_friendly_name.friendly_name_size = ANTFS_FRIENDLY_NAME_MAX;
-                        }
-
-                        m_friendly_name.index = 0;
-                    }
-                }
-                else
-                {
-                    // Next burst packets: read host friendly name.
-
-                    if (m_friendly_name.index < ANTFS_FRIENDLY_NAME_MAX)
-                    {
-                        uint32_t num_of_bytes = ANTFS_FRIENDLY_NAME_MAX - m_friendly_name.index;
-                        if (num_of_bytes > 8u)
-                        {
-                            num_of_bytes = 8u;
-                        }
-                        memcpy((uint8_t*)&m_friendly_name.friendly_name[m_friendly_name.index],
-                               p_command_buffer,
-                               num_of_bytes);
-                        m_friendly_name.index += num_of_bytes;
-                    }
-                }
-
-                if (control_byte & SEQUENCE_LAST_MESSAGE)
-                {
-                    // Last burst packet.
-
-                    timeout_start(ANTFS_CONFIG_PAIRING_TIMEOUT);
-                    if (m_friendly_name.friendly_name_size > 0)
-                    {
-                        m_friendly_name.is_name_set = true;
-                    }
-
-                    m_current_state.sub_state.auth_sub_state = ANTFS_AUTH_SUBSTATE_PAIR;
-                    // If pairing is supported, send request to UI.
-                    event_queue_write(ANTFS_EVENT_PAIRING_REQUEST);
-                }
-                break;
-
-#endif // ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED
-#if ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED
-            case COMMAND_TYPE_REQUEST_PASSKEY:
-                if ((control_byte & SEQUENCE_NUMBER_ROLLOVER) == 0)
-                {
-                    // First burst packet.
-
-                    // Passkey length.
-                    const uint32_t passkey_size = p_command_buffer[AUTH_STRING_LENGTH_OFFSET];
-
-                    // Default the algorithm to accept.
-                    response = AUTH_RESPONSE_ACCEPT;
-
-                    // Check if the passkey length is valid.
-                    if (passkey_size == ANTFS_PASSKEY_SIZE)
-                    {
-                        m_passkey_index = 0;
-                    }
-                    else
-                    {
-                        // Invalid lenght supplied - the authentication will be rejected.
-                        response = AUTH_RESPONSE_REJECT;
-                    }
-                }
-                else
-                {
-                    // Next burst packets: read host friendly name.
-
-                    if ((response == AUTH_RESPONSE_ACCEPT) &&
-                        // Prevent buffer overrun.
-                        (m_passkey_index != ANTFS_PASSKEY_SIZE))
-                    {
-                        // Passkey length was valid and the host supplied key matches so far.
-                        uint32_t idx = 0;
-
-                        // Check the current received burst packet for passkey match.
-                        do
-                        {
-                            if (m_initial_parameters.p_pass_key[m_passkey_index++] !=
-                                p_command_buffer[idx])
-                            {
-                                // Reject the authentication request and further processing of
-                                // passkey matching if a mismatch is found.
-                                response = AUTH_RESPONSE_REJECT;
-                                break;
-                            }
-
-                            ++idx;
-                        }
-                        while (idx < BURST_PACKET_SIZE);
-                    }
-                }
-
-                if (control_byte & SEQUENCE_LAST_MESSAGE)
-                {
-                    // Last burst packet.
-
-                    if (m_passkey_index < ANTFS_PASSKEY_SIZE)
-                    {
-                        // We did not get the complete passkey, reject authentication request.
-                        response = AUTH_RESPONSE_REJECT;
-                    }
-
-                    timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-                    m_current_state.sub_state.auth_sub_state = ANTFS_AUTH_SUBSTATE_PASSKEY;
-                    authenticate_response_transmit(response, 0, NULL);
-                }
-                break;
-
-#endif // ANTFS_CONFIG_AUTH_TYPE_PASSKEY_ENABLED
-            default:
-                break;
-        }
-    }
-    else if (p_command_buffer[ANTFS_COMMAND_OFFSET] == ANTFS_CMD_DISCONNECT_ID)
-    {
-        if (control_byte & SEQUENCE_LAST_MESSAGE)
-        {
-            // Don't do anything before the burst completes (last burst message received).
-            link_layer_transit();
-        }
-    }
-    else if (p_command_buffer[ANTFS_COMMAND_OFFSET] == ANTFS_CMD_PING_ID)
-    {
-        // Reset timeout.
-        timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-        m_link_command_in_progress = ANTFS_CMD_NONE;
-    }
-    else
-    {
-        // No implementation needed.
-    }
-}
-
-
-/**@brief Function for decoding an ANT-FS command received at the transport layer.
- *
- * @param[in] control_byte     The command control byte.
- * @param[in] p_command_buffer The ANT-FS command buffer.
- */
-static void transport_layer_cmd_decode(uint8_t control_byte, const uint8_t * p_command_buffer)
-{
-    ulong_union_t host_serial_number = {0};
-
-    if (p_command_buffer[ANTFS_CONNECTION_TYPE_OFFSET] == ANTFS_COMMAND_ID)
-    {
-        m_link_command_in_progress = p_command_buffer[ANTFS_COMMAND_OFFSET];
-    }
-
-    switch (m_link_command_in_progress)
-    {
-        case ANTFS_CMD_PING_ID:
-            // Reset timeout.
-            timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-            m_link_command_in_progress = ANTFS_CMD_NONE;
-            break;
-
-        case ANTFS_CMD_DISCONNECT_ID:
-            if (control_byte & SEQUENCE_LAST_MESSAGE)
-            {
-                // Don't do anything before the burst completes (last burst message received).
-                link_layer_transit();
-            }
-            break;
-
-        case ANTFS_CMD_ERASE_ID:
-            if (control_byte & SEQUENCE_LAST_MESSAGE)
-            {
-                // Don't do anything before the burst completes (last burst message received).
-
-                // Requested index.
-                m_file_index.bytes.low  = p_command_buffer[DATA_INDEX_OFFSET_LOW];
-                m_file_index.bytes.high = p_command_buffer[DATA_INDEX_OFFSET_HIGH];
-
-                // Send erase request to the application.
-                event_queue_write(ANTFS_EVENT_ERASE_REQUEST);
-                timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-                m_link_command_in_progress = ANTFS_CMD_ERASE_ID;
-            }
-            break;
-
-        case ANTFS_CMD_DOWNLOAD_ID:
-            if (m_current_state.sub_state.trans_sub_state != ANTFS_TRANS_SUBSTATE_NONE)
-            {
-                // Ignore the command if we are busy.
-                break;
-            }
-
-            if ((control_byte & ~SEQUENCE_LAST_MESSAGE) == 0x00)
-            {
-                // First burst packet.
-
-                if ((m_file_index.bytes.low != p_command_buffer[DATA_INDEX_OFFSET_LOW]) ||
-                    (m_file_index.bytes.high != p_command_buffer[DATA_INDEX_OFFSET_HIGH]))
-                {
-                    // This is a new index, so we can not check the CRC against the previous saved
-                    // CRC.
-
-                    // CRC seed checking is made invalid by setting the last saved offset to the
-                    // maximum file size.
-                    m_saved_crc_offset = ANTFS_MAX_FILE_SIZE;
-                }
-
-                // Requested data file index.
-                m_file_index.bytes.low  = p_command_buffer[DATA_INDEX_OFFSET_LOW];
-                m_file_index.bytes.high = p_command_buffer[DATA_INDEX_OFFSET_HIGH];
-
-                // Initialize current position in the TX burst to the requested offset.
-                m_link_burst_index.bytes.byte0 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_0];
-                m_link_burst_index.bytes.byte1 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_1];
-                m_link_burst_index.bytes.byte2 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_2];
-                m_link_burst_index.bytes.byte3 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_3];
-            }
-            else if (control_byte & SEQUENCE_LAST_MESSAGE)
-            {
-                // Last burst packet (download command should be two packets long).
-
-                // Get CRC seed from host.
-                m_compared_crc  = (uint16_t)p_command_buffer[DATA_INDEX_OFFSET_LOW];
-                m_compared_crc |= ((uint16_t)p_command_buffer[DATA_INDEX_OFFSET_HIGH] << 8u);
-
-                // Maximum block size allowed by host.
-                m_max_block_size.bytes.byte0 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_0];
-                m_max_block_size.bytes.byte1 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_1];
-                m_max_block_size.bytes.byte2 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_2];
-                m_max_block_size.bytes.byte3 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_3];
-
-                // Initialize number of remaining bytes for this block to the maximum block size.
-                m_bytes_remaining.data = m_max_block_size.data;
-
-                if (p_command_buffer[INITIAL_REQUEST_OFFSET])
-                {
-                    // This request is the start of a new transfer.
-
-                    // Initialize data offset for CRC calculation to the requested data offset.
-                    m_saved_crc_offset = m_link_burst_index.data;
-                    m_saved_buffer_crc_offset = m_link_burst_index.data;
-
-                    // Use CRC seed provided by host for CRC checking of the data.
-                    m_transfer_crc                            = m_compared_crc;
-                    m_saved_transfer_crc                      = m_compared_crc;
-                    m_saved_buffer_crc                        = m_compared_crc;
-                    m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_VERIFY_CRC;
-                }
-                else
-                {
-                    // This is a request to resume a partially completed transfer.
-
-                    if (m_saved_crc_offset > m_link_burst_index.data)
-                    {
-                        // We can not check the received CRC seed as the requested offset is before
-                        // our last save point.
-
-                        // Set CRC checking as invalid.
-                        m_saved_crc_offset = ANTFS_MAX_FILE_SIZE;
-                    }
-                    else
-                    {
-                        m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_VERIFY_CRC;
-                    }
-                }
-
-                m_is_data_request_pending = false;
-
-                // Send download request to the application for further handling.
-                event_queue_write(ANTFS_EVENT_DOWNLOAD_REQUEST);
-
-                timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-                m_link_command_in_progress = ANTFS_CMD_DOWNLOAD_ID;
-            }
-            break;
-
-        case ANTFS_CMD_UPLOAD_REQUEST_ID:
-#if ANTFS_CONFIG_UPLOAD_ENABLED
-            if ((control_byte & ~SEQUENCE_LAST_MESSAGE) == 0x00)
-            {
-                // First burst packet.
-
-                if ((m_file_index.bytes.low != p_command_buffer[DATA_INDEX_OFFSET_LOW]) ||
-                    (
-                        (m_file_index.bytes.high != p_command_buffer[DATA_INDEX_OFFSET_HIGH]) ||
-                        (m_current_state.sub_state.trans_sub_state == ANTFS_TRANS_SUBSTATE_NONE)
-                    )
-                   )
-                {
-                    // If it is a new index or we completed the last upload.
-
-                    // Get the file index.
-                    m_file_index.bytes.low  = p_command_buffer[DATA_INDEX_OFFSET_LOW];
-                    m_file_index.bytes.high = p_command_buffer[DATA_INDEX_OFFSET_HIGH];
-
-                    // As this is a new upload, reset save point to the beginning of the file.
-
-                    // Set CRC to zero.
-                    m_saved_crc_offset   = 0;
-                    m_saved_transfer_crc = 0;
-                }
-
-                // Get the upper limit of upload from request message.
-                m_max_transfer_index.bytes.byte0 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_0];
-                m_max_transfer_index.bytes.byte1 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_1];
-                m_max_transfer_index.bytes.byte2 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_2];
-                m_max_transfer_index.bytes.byte3 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_3];
-            }
-            else if (control_byte & SEQUENCE_LAST_MESSAGE)
-            {
-                // Last burst (second) packet.
-
-                // Get data offset the requested upload will start at.
-                m_link_burst_index.bytes.byte0 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_0];
-                m_link_burst_index.bytes.byte1 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_1];
-                m_link_burst_index.bytes.byte2 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_2];
-                m_link_burst_index.bytes.byte3 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_3];
-
-                if (m_link_burst_index.data != ANTFS_MAX_FILE_SIZE)
-                {
-                    // If this is a new upload.
-
-                    // The data offset specified in the upload request will be used.
-                    m_saved_crc_offset = m_link_burst_index.data;
-
-                    m_saved_transfer_crc = 0;
-                }
-
-                m_transfer_crc = m_saved_transfer_crc;
-
-                // Send upload request to the application for further handling.
-                event_queue_write(ANTFS_EVENT_UPLOAD_REQUEST);
-
-                timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-                m_link_command_in_progress = ANTFS_CMD_UPLOAD_REQUEST_ID;
-            }
-#endif  // ANTFS_CONFIG_UPLOAD_ENABLED
-            break;
-
-        case ANTFS_CMD_UPLOAD_DATA_ID:
-#if ANTFS_CONFIG_UPLOAD_ENABLED
-            if ((control_byte & ~SEQUENCE_LAST_MESSAGE) == 0x00)
-            {
-                // First burst packet.
-
-                if (m_current_state.sub_state.trans_sub_state ==
-                    ANTFS_TRANS_SUBSTATE_UPLOAD_WAIT_FOR_DATA)
-                {
-                    antfs_event_t event;
-
-                    // Get CRC Seed from host.
-                    m_compared_crc  = (uint16_t)p_command_buffer[DATA_INDEX_OFFSET_LOW];
-                    m_compared_crc |= ((uint16_t)p_command_buffer[DATA_INDEX_OFFSET_HIGH] << 8u);
-
-                    // Set download offset.
-                    m_link_burst_index.bytes.byte0 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_0];
-                    m_link_burst_index.bytes.byte1 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_1];
-                    m_link_burst_index.bytes.byte2 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_2];
-                    m_link_burst_index.bytes.byte3 = p_command_buffer[ADDRESS_PARAMETER_OFFSET_3];
-
-                    if ((m_link_burst_index.data + m_block_size.data) < m_max_transfer_index.data)
-                    {
-                        // Adjust block size as set by client.
-                        m_max_transfer_index.data = m_link_burst_index.data + m_block_size.data;
-                    }
-
-                    if (m_compared_crc != m_transfer_crc)
-                    {
-                        // Check that the request matches the CRC sent on the upload response.
-
-                        // Do not accept any data.
-                        m_max_transfer_index.data = 0;
-
-                        // Failure will be reported when upload is done.
-                        event = (antfs_event_t)0;
-                    }
-
-                    // Set ready to receive a file.
-                    m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_UPLOADING;
-
-                    event          = ANTFS_EVENT_UPLOAD_START;
-                    m_transfer_crc = m_compared_crc;
-
-                    if (m_link_burst_index.data > m_max_transfer_index.data)
-                    {
-                        // If the requested offset is too high.
-
-                        // Clear the max transfer index, so we'll report fail when the transfer
-                        // finishes.
-                        m_max_transfer_index.data = 0;
-                        // Clear the event because we normally would not send an event at this point
-                        // in this case.
-                        event = (antfs_event_t)0;
-                    }
-
-                    if (control_byte & SEQUENCE_LAST_MESSAGE)
-                    {
-                        // If this upload contains no data.
-
-                        // Leave the upload state.
-                        m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_NONE;
-
-                        // if it was a valid index, report it as a successful upload, otherwise
-                        // report it as a failure.
-                        if (event == 0)
-                        {
-                            event = ANTFS_EVENT_UPLOAD_FAIL;
-                        }
-                        else
-                        {
-                            event = ANTFS_EVENT_UPLOAD_COMPLETE;
-                        }
-                    }
-
-                    if (event != 0)
-                    {
-                        event_queue_write(event);
-                    }
-                }
-            }
-#endif // ANTFS_CONFIG_UPLOAD_ENABLED
-            break;
-
-        case ANTFS_CMD_LINK_ID:
-            host_serial_number.bytes.byte0 = p_command_buffer[HOST_ID_OFFSET_0];
-            host_serial_number.bytes.byte1 = p_command_buffer[HOST_ID_OFFSET_1];
-            host_serial_number.bytes.byte2 = p_command_buffer[HOST_ID_OFFSET_2];
-            host_serial_number.bytes.byte3 = p_command_buffer[HOST_ID_OFFSET_3];
-
-            if (m_link_host_serial_number.data == host_serial_number.data)
-            {
-                m_active_beacon_frequency = p_command_buffer[TRANSPORT_CHANNEL_FREQUENCY_OFFSET];
-                m_active_beacon_status1_field.parameters.link_period =
-                    p_command_buffer[TRANSPORT_MESSAGE_PERIOD_OFFSET];
-
-                const uint32_t err_code = sd_ant_channel_radio_freq_set(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                                        m_active_beacon_frequency);
-                APP_ERROR_CHECK(err_code);
-
-                channel_period_set(m_active_beacon_status1_field.parameters.link_period);
-            }
-
-            m_link_command_in_progress = 0;
-            break;
-
-        default:
-            // Don't do anything, this is an invalid message.
-            m_link_command_in_progress = 0;
-            break;
-    }
-}
-
-
-/**@brief Function for handling data upload.
- *
- * @param[in] control_byte     The command control byte.
- * @param[in] p_buffer         The data buffer.
- */
-static void upload_data_process(uint8_t control_byte, const uint8_t * p_buffer)
-{
-#if ANTFS_CONFIG_UPLOAD_ENABLED
-    if (control_byte & SEQUENCE_LAST_MESSAGE)
-    {
-        // Last burst packet: upload complete.
-
-        m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_NONE;
-
-        // CRC for data packets contained in this upload block.
-        m_compared_crc  = p_buffer[UPLOAD_CRC_OFFSET_LOW ];
-        m_compared_crc |= (p_buffer[UPLOAD_CRC_OFFSET_HIGH] << 8u);
-
-        if (m_max_transfer_index.data && (m_compared_crc == m_transfer_crc))
-        {
-            // CRC OK, upload was completed successfully.
-            event_queue_write(ANTFS_EVENT_UPLOAD_COMPLETE);
-        }
-        else
-        {
-            // CRC mismatch, upload failed.
-            event_queue_write(ANTFS_EVENT_UPLOAD_FAIL);
-        }
-
-        m_max_transfer_index.data = 0;
-    }
-    else
-    {
-        // Not the last burst packet: upload not complete.
-
-        // Set initial number of bytes to 8 (size of burst packet).
-        m_bytes_to_write = BURST_PACKET_SIZE;
-        timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-
-        if (m_link_burst_index.data > m_max_transfer_index.data)
-        {
-            // We are past the main index, we do not need to write any more data.
-            m_bytes_to_write = 0;
-        }
-        else
-        {
-            if ((m_bytes_to_write + m_link_burst_index.data) > m_max_transfer_index.data)
-            {
-                // if we're less than 8 bytes away from the end, adjust the number of bytes to write
-                // in this block.
-                m_bytes_to_write = m_max_transfer_index.data - m_link_burst_index.data;
-            }
-        }
-
-        if (m_bytes_to_write != 0)
-        {
-            APP_ERROR_CHECK_BOOL(m_bytes_to_write <= BURST_PACKET_SIZE);
-
-            // Store begin of upload data.
-            mp_upload_data = p_buffer;
-
-            m_transfer_crc = crc_crc16_update(m_transfer_crc, p_buffer, m_bytes_to_write);
-
-            // Send data to application.
-            event_queue_write(ANTFS_EVENT_UPLOAD_DATA);
-
-            // Update current offset.
-            m_link_burst_index.data += m_bytes_to_write;
-
-            // Store save point.
-            m_saved_crc_offset       = m_link_burst_index.data;
-            m_saved_transfer_crc     = m_transfer_crc;
-        }
-    }
-#endif // ANTFS_CONFIG_UPLOAD_ENABLED
-}
-
-
-/**@brief Function for switching to transport layer.
- */
-static void transport_layer_transit(void)
-{
-    if (m_current_state.state != ANTFS_STATE_OFF)
-    {
-#if ANTFS_CONFIG_DEBUG_LED_ENABLED
-        uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
-        APP_ERROR_CHECK(err_code);
-#endif // ANTFS_CONFIG_DEBUG_LED_ENABLED
-        m_current_state.state                     = ANTFS_STATE_TRANS;
-        m_current_state.sub_state.trans_sub_state = ANTFS_TRANS_SUBSTATE_NONE;
-
-        timeout_start(ANTFS_CONFIG_LINK_COMMAND_TIMEOUT);
-
-        beacon_transmit(MESG_BROADCAST_DATA_ID);
-
-        event_queue_write(ANTFS_EVENT_TRANS);
-    }
-}
-
-
-void antfs_message_process(uint8_t * p_message)
-{
-#if ANTFS_CONFIG_DEBUG_LED_ENABLED
-    uint32_t err_code;
-#endif // ANTFS_CONFIG_DEBUG_LED_ENABLED
-
-    if (p_message != NULL)
-    {
-        if ((p_message[BUFFER_INDEX_CHANNEL_NUM] & CHANNEL_NUMBER_MASK) != ANTFS_CONFIG_CHANNEL_NUMBER)
-        {
-            // Only process messages corresponding to the ANT-FS channel here.
-            return;
-        }
-
-        if ((m_current_state.state == ANTFS_STATE_OFF) &&
-            (
-                !(
-                    (p_message[BUFFER_INDEX_MESG_ID] == MESG_RESPONSE_EVENT_ID) &&
-                    (p_message[BUFFER_INDEX_RESPONSE_CODE] == NO_EVENT)
-                  )
-            )
-           )
-        {
-            return;
-        }
-
-        switch (p_message[BUFFER_INDEX_MESG_ID])
-        {
-            case MESG_BROADCAST_DATA_ID:
-                // We are not going to process broadcast messages or pass them to the app to handle.
-                break;
-
-            case MESG_ACKNOWLEDGED_DATA_ID:
-                // Mark it as being the last message if it's an ack message.
-                p_message[ANTFS_CONTROL_OFFSET] |= SEQUENCE_LAST_MESSAGE;
-
-            /* fall-through */
-            case MESG_BURST_DATA_ID:
-                switch (m_current_state.state)
-                {
-                    case ANTFS_STATE_LINK:
-                        link_layer_cmd_decode(&p_message[ANTFS_DATA_OFFSET]);
-                        break;
-
-                    case ANTFS_STATE_AUTH:
-                        authenticate_layer_cmd_decode(p_message[ANTFS_CONTROL_OFFSET],
-                                                      &p_message[ANTFS_DATA_OFFSET]);
-                        break;
-
-                    case ANTFS_STATE_TRANS:
-                        if (m_current_state.sub_state.trans_sub_state !=
-                            ANTFS_TRANS_SUBSTATE_UPLOADING)
-                        {
-                            transport_layer_cmd_decode(p_message[ANTFS_CONTROL_OFFSET],
-                                                       &p_message[ANTFS_DATA_OFFSET]);
-                        }
-                        else
-                        {
-                            upload_data_process(p_message[ANTFS_CONTROL_OFFSET],
-                                                &p_message[ANTFS_DATA_OFFSET]);
-                        }
-                        break;
-
-                    default:
-                        // If in any other state or sub-state, do nothing.
-                        break;
-                }
-                break;
-
-            case MESG_RESPONSE_EVENT_ID:
-                // Branch on event ID.
-                switch (p_message[BUFFER_INDEX_RESPONSE_CODE])
-                {
-                    case EVENT_TRANSFER_TX_FAILED:
-                        m_link_command_in_progress = ANTFS_CMD_NONE;
-                        // Switch into the appropriate state after the failure. Must be ready for
-                        // the host to do a retry.
-                        switch (m_current_state.state)
-                        {
-                            case ANTFS_STATE_LINK:
-                                link_layer_transit();
-                                break;
-
-                            case ANTFS_STATE_AUTH:
-                                // Burst failed, retry sending the response
-                                if (!m_retry)
-                                {
-                                    authenticate_layer_transit(); // Reload beacon
-                                }
-                                else
-                                {
-                                    if (m_current_state.sub_state.auth_sub_state == ANTFS_AUTH_SUBSTATE_ACCEPT)
-                                    {
-                                        if (m_authenticate_command_type == COMMAND_TYPE_REQUEST_PAIR)
-                                        {
-                                            authenticate_response_transmit(AUTH_RESPONSE_ACCEPT, ANTFS_PASSKEY_SIZE,
-                                               m_initial_parameters.p_pass_key);
-                                        }
-                                        else
-                                        {
-                                            authenticate_response_transmit(AUTH_RESPONSE_ACCEPT, 0, NULL);
-                                        }
-                                    }
-                                    else if (m_current_state.sub_state.auth_sub_state == ANTFS_AUTH_SUBSTATE_REJECT)
-                                    {
-                                        authenticate_response_transmit(AUTH_RESPONSE_REJECT, 0, NULL);
-                                    }
-                                    else if (m_authenticate_command_type == COMMAND_TYPE_REQUEST_SERIAL)
-                                    {
-                                        authenticate_response_transmit(AUTH_RESPONSE_N_A,
-                                                           ANTFS_REMOTE_FRIENDLY_NAME_MAX,
-                                                           // Send device friendly name if it exists.
-                                                           m_initial_parameters.p_remote_friendly_name);
-                                    }
-                                    else
-                                    {
-                                        // No implementation needed
-                                    }
-
-                                    m_retry--;
-                                }
-
-                                break;
-
-                            case ANTFS_STATE_TRANS:
-                                if (m_current_state.sub_state.trans_sub_state ==
-                                    ANTFS_TRANS_SUBSTATE_DOWNLOADING)
-                                {
-                                    event_queue_write(ANTFS_EVENT_DOWNLOAD_FAIL);
-                                }
-                                transport_layer_transit();
-                                break;
-
-                            default:
-                                // No implementation needed.
-                                break;
-                        }
-                        break;
-
-                    case EVENT_TRANSFER_RX_FAILED:
-                        m_link_command_in_progress = ANTFS_CMD_NONE;
-
-                        if (m_current_state.sub_state.trans_sub_state ==
-                            ANTFS_TRANS_SUBSTATE_UPLOADING)
-                        {
-                            event_queue_write(ANTFS_EVENT_UPLOAD_FAIL);
-
-                            m_current_state.sub_state.trans_sub_state =
-                                ANTFS_TRANS_SUBSTATE_UPLOAD_RESUME;
-                        }
-                        else
-                        {
-                            // No implementation needed
-                        }
-
-                        break;
-
-                    case EVENT_TRANSFER_TX_COMPLETED:
-                        m_link_command_in_progress = ANTFS_CMD_NONE;
-
-                        // Switch into appropiate state after successful command.
-                        switch (m_current_state.state)
-                        {
-                            case ANTFS_STATE_AUTH:
-                                if (m_current_state.sub_state.auth_sub_state ==
-                                    ANTFS_AUTH_SUBSTATE_ACCEPT)
-                                {
-                                    // We passed authentication, so go to transport state.
-                                    transport_layer_transit();
-                                }
-                                else if (m_current_state.sub_state.auth_sub_state ==
-                                         ANTFS_AUTH_SUBSTATE_REJECT)
-                                {
-                                    // We failed authentication, so go to link state.
-                                    link_layer_transit();
-                                }
-                                else
-                                {
-                                    // Reload beacon.
-                                    authenticate_layer_transit();
-                                }
-                                break;
-
-                            case ANTFS_STATE_TRANS:
-                                if (m_current_state.sub_state.trans_sub_state ==
-                                    ANTFS_TRANS_SUBSTATE_DOWNLOADING)
-                                {
-                                    event_queue_write(ANTFS_EVENT_DOWNLOAD_COMPLETE);
-                                }
-                                if (m_current_state.sub_state.trans_sub_state !=
-                                    ANTFS_TRANS_SUBSTATE_UPLOAD_WAIT_FOR_DATA)
-                                {
-                                    transport_layer_transit();  // Reload beacon.
-                                }
-                                break;
-
-                            default:
-                                link_layer_transit();       // Reload beacon.
-                                break;
-                        }
-                        break;
-
-                    case EVENT_TX:
-#if ANTFS_CONFIG_DEBUG_LED_ENABLED
-                        err_code = bsp_indication_set(BSP_INDICATE_SENT_OK);
-                        APP_ERROR_CHECK(err_code);
-#endif // ANTFS_CONFIG_DEBUG_LED_ENABLED
-                        // Load beacon.
-                        beacon_transmit(MESG_BROADCAST_DATA_ID);
-                        break;
-
-                    case EVENT_CHANNEL_CLOSED:
-                        event_queue_write(ANTFS_EVENT_CLOSE_COMPLETE);
-                        break;
-
-                    case NO_EVENT:
-                        // This shouldn't happen... command responses should not occur.
-                        APP_ERROR_HANDLER(p_message[BUFFER_INDEX_RESPONSE_CODE]);
-                        break;
-
-                    default:
-                        // No implementation needed.
-                        return;
-                }
-                break;
-
-            default:
-                // No implementation needed.
-                return;
-        }
-    }
-}
-
-
-void antfs_channel_setup(void)
-{
-    // Start channel configuration.
-    uint32_t err_code = ant_fs_key_set(ANTFS_CONFIG_NETWORK_NUMBER);
-    APP_ERROR_CHECK(err_code);
-
-    err_code = sd_ant_channel_assign(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                     ANTFS_CHANNEL_TYPE,
-                                     ANTFS_CONFIG_NETWORK_NUMBER,
-                                     0);
-    APP_ERROR_CHECK(err_code);
-
-    // Use the lower 2 bytes of the ESN for device number.
-    uint16_t device_number = (uint16_t)(m_initial_parameters.client_serial_number & 0x0000FFFFu);
-    if (device_number == 0)
-    {
-        // Device number of 0 is not allowed.
-        device_number = 2;
-    }
-
-    err_code = sd_ant_channel_id_set(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                     device_number,
-                                     ANTFS_CONFIG_DEVICE_TYPE,
-                                     ANTFS_CONFIG_TRANS_TYPE);
-    APP_ERROR_CHECK(err_code);
-
-    // Remain in initialization state until channel is open.
-    m_current_state.state = ANTFS_STATE_INIT;
-    // @note: Channel frequency is set by function below.
-    link_layer_transit();
-    m_current_state.state = ANTFS_STATE_INIT;
-
-    channel_period_set(m_active_beacon_status1_field.parameters.link_period);
-
-    err_code = sd_ant_channel_open(ANTFS_CONFIG_CHANNEL_NUMBER);
-    APP_ERROR_CHECK(err_code);
-
-    err_code = sd_ant_channel_radio_tx_power_set(ANTFS_CONFIG_CHANNEL_NUMBER,
-                                                 ANTFS_CONFIG_TRANSMIT_POWER,
-                                                 ANTFS_CONFIG_CUSTOM_TRANSMIT_POWER);
-    APP_ERROR_CHECK(err_code);
-
-    m_current_state.state                    = ANTFS_STATE_LINK;
-    m_current_state.sub_state.link_sub_state = ANTFS_LINK_SUBSTATE_NONE;
-
-    event_queue_write(ANTFS_EVENT_OPEN_COMPLETE);
-
-    // Start beacon broadcast.
-    beacon_transmit(MESG_BROADCAST_DATA_ID);
-}
-
-
-/**@brief Function for resetting the ANT-FS state machine.
- */
-static void state_machine_reset(void)
-{
-    m_current_state.state      = ANTFS_STATE_OFF;
-    m_link_command_in_progress = ANTFS_CMD_NONE;
-
-    timeout_disable();
-
-    // Reset the ANT-FS event queue.
-    m_event_queue.p_queue = m_event_queue_buffer;
-    m_event_queue.head    = 0;
-    m_event_queue.tail    = 0;
-
-    // Set as invalid.
-    m_authenticate_command_type = 0xFFu;
-    m_retry = 0;
-
-    m_saved_crc_offset        = 0xFFFFFFFFu;
-    m_max_transfer_index.data = 0;
-    m_is_crc_pending          = false;
-    m_is_data_request_pending = false;
-
-    m_friendly_name.is_name_set = false;
-    m_friendly_name.index       = 0;
-
-    memset(m_friendly_name.friendly_name, 0, ANTFS_FRIENDLY_NAME_MAX);
-}
-
-
-/**@brief Function for ANT-FS timer event.
- *
- * Handles pairing and command timeouts.
- *
- * @param[in] p_context        The callback context.
- */
-static void timeout_handle(void * p_context)
-{
-    if (m_current_state.state == ANTFS_STATE_OFF)
-    {
-        return;
-    }
-
-    if ((m_current_state.state == ANTFS_STATE_AUTH) &&
-        // Pairing timeout.
-        (m_current_state.sub_state.auth_sub_state == ANTFS_AUTH_SUBSTATE_PAIR))
-    {
-        // Reject authentication request and send pairing timeout event.
-        authenticate_response_transmit(AUTH_RESPONSE_REJECT, 0, NULL);
-        event_queue_write(ANTFS_EVENT_PAIRING_TIMEOUT);
-    }
-
-    // Fall back to link layer when an ANT-FS event times out.
-    link_layer_transit();
-}
-
-
-void antfs_init(const antfs_params_t * const p_params,
-                antfs_burst_wait_handler_t burst_wait_handler)
-{
-    m_initial_parameters          = *p_params;
-    m_burst_wait_handler          = burst_wait_handler;
-    m_active_beacon_status1_field = m_initial_parameters.beacon_status_byte1;
-
-    uint32_t err_code = app_timer_create(&m_timer_id, APP_TIMER_MODE_SINGLE_SHOT, timeout_handle);
-    APP_ERROR_CHECK(err_code);
-
-    state_machine_reset();
-
-    err_code = sd_ant_burst_handler_wait_flag_enable((uint8_t *)(&m_burst_wait));
-    APP_ERROR_CHECK(err_code);
-}
-#endif // NRF_MODULE_ENABLED(ANTFS)

+ 0 - 396
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/antfs.h

@@ -1,396 +0,0 @@
-/**
- * This software is subject to the ANT+ Shared Source License
- * www.thisisant.com/swlicenses
- * Copyright (c) Dynastream Innovations, Inc. 2012
- * 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 Dynastream nor the names of its
- *    contributors may be used to endorse or promote products
- *    derived from this software without specific prior
- *    written permission.
- * 
- * The following actions are prohibited:
- * 1) Redistribution of source code containing the ANT+ Network
- *    Key. The ANT+ Network Key is available to ANT+ Adopters.
- *    Please refer to http://thisisant.com to become an ANT+
- *    Adopter and access the key.
- * 
- * 2) Reverse engineering, decompilation, and/or disassembly of
- *    software provided in binary form under this 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 HEREBY
- * 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; DAMAGE TO ANY DEVICE, 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. SOME STATES DO NOT ALLOW
- * THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE
- * ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
- * 
- */
-/**@file
- * @brief The ANT-FS client protocol interface.
- * This file is based on implementation originally made by Dynastream Innovations Inc. - August 2012
- * @defgroup ant_fs ANT-FS client device simulator
- * @{
- * @ingroup ant_sdk_utils
- *
- * @brief The ANT-FS client device simulator.
- *
- * @note The ANT-FS Network Key is available for ANT+ Adopters. Please refer to http://thisisant.com to become an ANT+ Adopter and access the key.
- */
-
-#ifndef ANTFS_H__
-#define ANTFS_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "defines.h"
-#include "sdk_config.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ANTFS_VERSION_MAJOR               1u                                                                                             /**< Version major number. */
-#define ANTFS_VERSION_MINOR               0                                                                                              /**< Version minor number. */
-#define ANTFS_VERSION_ITERATION           0                                                                                              /**< Version iteration. */
-#define ANTFS_VERSION_TYPE                'R'                                                                                            /**< Version type is release. */
-#define ANTFS_VERSION_SPEC                '0.AK'                                                                                         /**< Version of the ANT-FS Technology Specification. */
-#define ANTFS_DIR_STRUCT_VERSION          1u                                                                                             /**< Version of the directory file structure. */
-#define ANTFS_VERSION_DATE                20090522u                                                                                      /**< Version date. */
-
-// ANT-FS options.
-#define ANTFS_LINK_FREQ                   50u                                                                                            /**< RF Frequency (+2400MHz). */
-#define ANTFS_CHANNEL_TYPE                CHANNEL_TYPE_MASTER                                                                            /**< ANT-FS Client Channel Type. */
-#define ANTFS_AUTH_STRING_MAX             255u                                                                                           /**< Maximum size of authentication strings (passkey/friendly name). */
-#define ANTFS_PASSKEY_SIZE                16u                                                                                            /**< Passkey size. */
-#define ANTFS_FRIENDLY_NAME_MAX           16u                                                                                            /**< Maximum size of friendly name received from host. */
-#define ANTFS_REMOTE_FRIENDLY_NAME_MAX    16u                                                                                            /**< Maximum size of client's friendly name. */
-
-// Beacon definitions.
-#define BEACON_PERIOD_SHIFT               0x00                                                                                           /**< Shift value for masking out beacon period. */
-#define BEACON_PERIOD_MASK                (0x07u << BEACON_PERIOD_SHIFT)                                                                 /**< Beacon period bitmask. */
-#define BEACON_PERIOD_0_5_HZ              (0x00  << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 0,5Hz beacon period. */
-#define BEACON_PERIOD_1_HZ                (0x01u << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 1Hz beacon period. */
-#define BEACON_PERIOD_2_HZ                (0x02u << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 2Hz beacon period. */
-#define BEACON_PERIOD_4_HZ                (0x03u << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 4Hz beacon period. */
-#define BEACON_PERIOD_8_HZ                (0x04u << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 8Hz beacon period. */
-#define PAIRING_AVAILABLE_FLAG_SHIFT      0x03u                                                                                          /**< Shift value for masking out pairing enabled bit. */
-#define PAIRING_AVAILABLE_FLAG_MASK       (0x01u << PAIRING_AVAILABLE_FLAG_SHIFT)                                                        /**< Pairing enabled bitmask. */
-#define UPLOAD_ENABLED_FLAG_SHIFT         0x04u                                                                                          /**< Shift value for masking out upload enabled bit. */
-#define UPLOAD_ENABLED_FLAG_MASK          (0x01u << UPLOAD_ENABLED_FLAG_SHIFT)                                                           /**< Upload enabled bitmask. */
-#define DATA_AVAILABLE_FLAG_SHIFT         0x05u                                                                                          /**< Shift value for masking out data available bit. */
-#define DATA_AVAILABLE_FLAG_MASK          (0x01u << DATA_AVAILABLE_FLAG_SHIFT)                                                           /**< Data available bitmask. */
-
-#if ANTFS_ENABLED
-// Build the default beacon settings.
-#if ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED
-   #define ANTFS_PAIRING_BIT              PAIRING_AVAILABLE_FLAG_MASK                                                                    /**< Build pairing enabled default beacon setting. */
-#else
-   #define ANTFS_PAIRING_BIT              0x00u                                                                                          /**< Build pairing disabled default beacon setting. */
-#endif // ANTFS_CONFIG_AUTH_TYPE_PAIRING_ENABLED
-#if ANTFS_CONFIG_UPLOAD_ENABLED
-   #define ANTFS_UPLOAD_BIT               UPLOAD_ENABLED_FLAG_MASK                                                                       /**< Build upload enabled default beacon setting. */
-#else
-   #define ANTFS_UPLOAD_BIT               0x00u                                                                                          /**< Build upload disabled default beacon setting. */
-#endif // ANTFS_CONFIG_UPLOAD_ENABLED
-
-#define ANTFS_DEFAULT_BEACON              (ANTFS_CONFIG_BEACON_STATUS_PERIOD | ANTFS_UPLOAD_BIT | ANTFS_PAIRING_BIT | DATA_AVAILABLE_FLAG_MASK) /**< Define the default beacon setting. */
-#endif // ANTFS_ENABLED
-
-// Download/Upload responses.
-#define RESPONSE_MESSAGE_OK               0x00u                                                                                          /**< Download request ok. */
-#define RESPONSE_MESSAGE_NOT_EXIST        0x01u                                                                                          /**< File does not exist. */
-#define RESPONSE_MESSAGE_NOT_AVAILABLE    0x02u                                                                                          /**< File can not be read/written to (download/upload respectively). */
-#define RESPONSE_INVALID_OPERATION        0x04u                                                                                          /**< Request invalid. */
-// Download responses.
-#define RESPONSE_MESSAGE_NOT_READY        0x03u                                                                                          /**< Not ready to download. */
-#define RESPONSE_INVALID_CRC              0x05u                                                                                          /**< CRC incorrect. */
-// Upload responses.
-#define RESPONSE_MESSAGE_NOT_ENOUGH_SPACE 0x03u                                                                                          /**< Not enough space to to complete write. */
-#define RESPONSE_MESSAGE_UPLOAD_NOT_READY 0x05u                                                                                          /**< Not ready to upload */
-// Upload/Erase responses.
-#define RESPONSE_MESSAGE_FAIL             0x01u                                                                                          /**< Data File Index does not exist / Erase failed. */
-
-// Directory general file flags.
-#define ANTFS_DIR_READ_MASK               0x80u                                                                                          /**< Read (can download). */
-#define ANTFS_DIR_WRITE_MASK              0x40u                                                                                          /**< Write (can upload). */
-#define ANTFS_DIR_ERASE_MASK              0x20u                                                                                          /**< Erase (can erase). */
-#define ANTFS_DIR_ARCHIVE_MASK            0x10u                                                                                          /**< Archive (has been downloaded). */
-#define ANTFS_DIR_APPEND_MASK             0x08u                                                                                          /**< Append (can append to file only). */
-
-#define ANTFS_MAX_FILE_SIZE               0xFFFFFFFFu                                                                                    /**< Maximum file size, as specified by directory structure. */
-#define ANTFS_BURST_BLOCK_SIZE            16u                                                                                            /**< Size of each block of burst data that the client attempts to send when it processes a data request event. */
-
-/**@brief ANT-FS beacon status. */
-typedef union
-{
-    uint32_t        status;                                     /**< Beacon status byte 1. */
-
-    struct
-    {
-        uint32_t    link_period         : 3;                    /**< Beacon period (0.5 - 8 Hz). */
-        bool        is_pairing_enabled  : 1;                    /**< Pairing is enabled/disabled. */
-        bool        is_upload_enabled   : 1;                    /**< Upload is enabled/disabled. */
-        bool        is_data_available   : 1;                    /**< Data is available for download / no data available. */
-        bool        reserved            : 2;                    /**< Reserved. */
-    } parameters;
-} antfs_beacon_status_byte1_t;
-
-// ANT-FS states.
-typedef enum
-{
-    ANTFS_STATE_OFF,                                            /**< Off state. */
-    ANTFS_STATE_INIT,                                           /**< Init state. */
-    ANTFS_STATE_LINK,                                           /**< Link state. */
-    ANTFS_STATE_AUTH,                                           /**< Authenticate state. */
-    ANTFS_STATE_TRANS                                           /**< Transport state. */
-} antfs_state_t;
-
-// ANT-FS link layer substates.
-typedef enum
-{
-    ANTFS_LINK_SUBSTATE_NONE                                    /**< None state. */
-} antfs_link_substate_t;
-
-// ANT-FS authenticate layer substates. */
-typedef enum
-{
-    ANTFS_AUTH_SUBSTATE_NONE,                                   /**< None state. */
-    ANTFS_AUTH_SUBSTATE_PAIR,                                   /**< Pairing state. */
-    ANTFS_AUTH_SUBSTATE_PASSKEY,                                /**< Passkey state. */
-    ANTFS_AUTH_SUBSTATE_ACCEPT,                                 /**< Authenticate accept state. */
-    ANTFS_AUTH_SUBSTATE_REJECT                                  /**< Authenticate reject state. */
-} antfs_authenticate_substate_t;
-
-// ANT-FS transport layer substates. */
-typedef enum
-{
-    ANTFS_TRANS_SUBSTATE_NONE,                                  /**< None state. */
-    ANTFS_TRANS_SUBSTATE_VERIFY_CRC,                            /**< Verify CRC state. */
-    ANTFS_TRANS_SUBSTATE_DOWNLOADING,                           /**< Downloading state. */
-    ANTFS_TRANS_SUBSTATE_UPLOAD_WAIT_FOR_DATA,                  /**< Wait for upload data request state. */
-    ANTFS_TRANS_SUBSTATE_UPLOADING,                             /**< Ready / receiving upload data state. */
-    ANTFS_TRANS_SUBSTATE_UPLOAD_RESUME                          /**< RX failure upon receiving upload data state. */
-} antfs_transport_substate_t;
-
-// ANT-FS Events.
-typedef enum
-{
-    ANTFS_EVENT_PAIRING_REQUEST =       0xB0,                   /**< Pairing request event. */
-    ANTFS_EVENT_PAIRING_TIMEOUT =       0xB1,                   /**< Pairing timeout event. */
-    ANTFS_EVENT_OPEN_COMPLETE =         0xB2,                   /**< Channel setup complete event. */
-    ANTFS_EVENT_CLOSE_COMPLETE =        0xB4,                   /**< Channel closed event. */
-    ANTFS_EVENT_LINK =                  0xB6,                   /**< Enter link layer event. */
-    ANTFS_EVENT_AUTH =                  0xB7,                   /**< Enter authenticate layer event. */
-    ANTFS_EVENT_TRANS =                 0xB8,                   /**< Enter transport layer event. */
-    ANTFS_EVENT_DOWNLOAD_REQUEST =      0xB9,                   /**< Download request event. */
-    ANTFS_EVENT_DOWNLOAD_REQUEST_DATA = 0xBA,                   /**< Download request data event. */
-    ANTFS_EVENT_DOWNLOAD_START  =       0xBB,                   /**< Download started event. */
-    ANTFS_EVENT_DOWNLOAD_COMPLETE =     0xBC,                   /**< Download completed event. */
-    ANTFS_EVENT_DOWNLOAD_FAIL =         0xBD,                   /**< Download failed event. */
-    ANTFS_EVENT_UPLOAD_REQUEST =        0xBE,                   /**< Upload request event. */
-    ANTFS_EVENT_UPLOAD_DATA =           0xBF,                   /**< Upload data available for read event. */
-    ANTFS_EVENT_UPLOAD_START  =         0xC0,                   /**< Upload begin event. */
-    ANTFS_EVENT_UPLOAD_COMPLETE =       0xC1,                   /**< Upload completed event. */
-    ANTFS_EVENT_UPLOAD_FAIL =           0xC2,                   /**< Upload process failed event. */
-    ANTFS_EVENT_ERASE_REQUEST =         0xC3                    /**< Erase request event. */
-} antfs_event_t;
-
-/**@brief ANT-FS <-> application event communication object. */
-typedef struct
-{
-    antfs_event_t event;                                        /**< ANT-FS event. */
-    uint16_t      file_index;                                   /**< File index (download/upload/erase). */
-    uint32_t      offset;                                       /**< Current offset (download/upload). */
-    uint32_t      bytes;                                        /**< Number of bytes in block (download/upload). */
-    uint16_t      crc;                                          /**< Current CRC (upload). */
-    uint8_t       data[8];                                      /**< Block of data (upload). */
-} antfs_event_return_t;
-
-/**@brief ANT-FS parameters. */
-typedef struct
-{
-    uint32_t                    client_serial_number;           /**< Client serial number. */
-    uint16_t                    beacon_device_type;             /**< Client device type. */
-    uint16_t                    beacon_device_manufacturing_id; /**< Client manufacturing ID. */
-    uint8_t                     beacon_frequency;               /**< Beacon RF Frequency. */
-    antfs_beacon_status_byte1_t beacon_status_byte1;            /**< Beacon status byte 1. */
-    const uint8_t *             p_pass_key;                     /**< Pass Key. */
-    const uint8_t *             p_remote_friendly_name;         /**< Friendly Name. */
-} antfs_params_t;
-
-/**@brief ANT-FS directory header. */
-typedef struct
-{
-    uint8_t  version;                                           /**< Version of the directory file structure. */
-    uint8_t  length;                                            /**< Length of each structure, in bytes. */
-    uint8_t  time_format;                                       /**< Defines how system keeps track of date/time stamps. */
-    uint8_t  reserved01;
-    uint8_t  reserved02;
-    uint8_t  reserved03;
-    uint8_t  reserved04;
-    uint8_t  reserved05;
-    uint32_t system_time;                                       /**< Number of seconds elapsed since system power up. */
-    uint32_t date;                                              /**< Number of seconds elapsed since 00:00 hrs Dec 31, 1989. If system time is unknown, used as counter. */
-} antfs_dir_header_t;
-
-/**@brief ANT-FS directory entry. */
-typedef struct
-{
-    uint16_t data_file_index;                                   /**< Data file index. */
-    uint8_t  file_data_type;                                    /**< File data type. */
-    uint8_t  user_defined1;                                     /**< Identifier, first byte (structure defined by data type). */
-    uint16_t user_defined2;                                     /**< Identifier, last two bytes (structure defined by data type). */
-    uint8_t  user_flags;                                        /**< File data type specific flags (bits defined by data type). */
-    uint8_t  general_flags;                                     /**< Bit mapped flags of flag permissions. */
-    uint32_t file_size_in_bytes;                                /**< File size, in bytes. */
-    uint32_t date;                                              /**< Number of seconds elapsed since 00:00 hrs Dec 31, 1980, if supported. */
-} antfs_dir_struct_t;
-
-/**@brief ANT-FS download/upload request context. */
-typedef struct
-{
-    ulong_union_t  file_size;                                   /**< Size of a file to download when reading, or the size of a partially completed upload when writing. */
-    uint32_t       max_file_size;                               /**< The maximum size of the file specified, this is the file size when reading, and the maximum allowed file size when writing. */
-    ulong_union_t  max_burst_block_size;                        /**< Maximum burst block size. */
-    ushort_union_t file_index;                                  /**< File index. */
-    uint16_t       file_crc;                                    /**< CRC (uploads). */
-} antfs_request_info_t;
-
-/**@brief The burst wait handler can be configured by the application to customize the code that is
- * executed while waiting for the burst busy flag. */
-typedef void(*antfs_burst_wait_handler_t)(void);
-
-/**@brief Function for setting initial ANT-FS configuration parameters.
- *
- * @param[in] p_params                 The initial ANT-FS configuration parameters.
- * @param[in] burst_wait_handler       Burst wait handler.
- */
-void antfs_init(const antfs_params_t * const p_params,
-                antfs_burst_wait_handler_t burst_wait_handler);
-
-/**@brief Function for getting host name if received.
- *
- * @return Pointer to host name buffer if a host name was recieved, NULL otherwise.
- */
-const char * antfs_hostname_get(void);
-
-/**@brief Function for transmitting a response to a pairing request issued by ANT-FS host.
- *
- * @param[in] accept              The pairing response, true if pairing accepted.
- *
- * @retval true  Operation success. Response to a pairing request was transmitted.
- * @retval false Operation failure. Not in pairing mode or pairing not supported by the
- *               implementation.
- */
-bool antfs_pairing_resp_transmit(bool accept);
-
-/**@brief Function for doing calculations prior downloading the data to the ANT-FS host.
- *
- * Function does the necessary pre processing calculations, which are required prior downloading the
- * data, and also transmits the download request response right away in case of the download request
- * was rejected or there is no data to send.
- *
- * @param[in] response            The download request response code.
- * @param[in] p_request_info      ANT-FS request info structure.
- */
-void antfs_download_req_resp_prepare(uint8_t response,
-                                             const antfs_request_info_t * const p_request_info);
-
-/**@brief Function for downloading requested data.
- *
- * @param[in] index               Index of the current file downloaded.
- * @param[in] offset              Offset specified by client.
- * @param[in] num_bytes           Number of bytes requested to be transmitted from the buffer.
- * @param[in] p_message           Data buffer to be transmitted.
- *
- * @return Number of data bytes transmitted.
- */
-uint32_t antfs_input_data_download(uint16_t index,
-                                   uint32_t offset,
-                                   uint32_t num_bytes,
-                                   const uint8_t * const p_message);
-
-/**@brief Function for transmitting upload request response to a upload request command by ANT-FS
- *        host.
- *
- * @param[in] response            The upload response code.
- * @param[in] p_request_info      ANT-FS request info structure.
- *
- * @retval true  Operation success. Response to upload request command was transmitted.
- * @retval false Operation failure. Upload not supported by the implementation or not in correct
- *                                  state or application is sending a response for a different file
- *                                  than requested.
- */
-bool antfs_upload_req_resp_transmit(uint8_t response,
-                                            const antfs_request_info_t * const p_request_info);
-
-/**@brief Function for transmitting upload data response to a upload data command by ANT-FS host.
- *
- * @param[in] data_upload_success The upload response code, true for success.
- *
- * @retval true  Operation success. Response to upload data command was transmitted.
- * @retval false Operation failure. Upload not supported by the implementation or not in correct
- *                                  state.
- */
-bool antfs_upload_data_resp_transmit(bool data_upload_success);
-
-/**@brief Function for transmitting erase response to a erase request.
- *
- * @param[in] response            The erase response code.
- */
-void antfs_erase_req_resp_transmit(uint8_t response);
-
-/**@brief Function for extracting possible pending ANT-FS event.
- *
- * @param[out] p_event            The output event structure.
- *
- * @retval true  Operation success. Pending ANT-FS event available and it was copied to the output
- *                                  event structure.
- * @retval false Operation failure. No pending ANT-FS event available.
- */
-bool antfs_event_extract(antfs_event_return_t * const p_event);
-
-/**@brief Function for processing ANT events and data received from the ANT-FS channel.
- *
- * @param[in] p_message           The message buffer containing the message received from the ANT-FS
- *                                channel.
- */
-void antfs_message_process(uint8_t * p_message);
-
-/**@brief Function for setting up the ANT-FS channel.
- */
-void antfs_channel_setup(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANTFS_H__
-
-/**
- *@}
- **/

+ 0 - 98
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/crc.c

@@ -1,98 +0,0 @@
-/**
- * This software is subject to the ANT+ Shared Source License
- * www.thisisant.com/swlicenses
- * Copyright (c) Dynastream Innovations, Inc. 2012
- * 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 Dynastream nor the names of its
- *    contributors may be used to endorse or promote products
- *    derived from this software without specific prior
- *    written permission.
- * 
- * The following actions are prohibited:
- * 1) Redistribution of source code containing the ANT+ Network
- *    Key. The ANT+ Network Key is available to ANT+ Adopters.
- *    Please refer to http://thisisant.com to become an ANT+
- *    Adopter and access the key.
- * 
- * 2) Reverse engineering, decompilation, and/or disassembly of
- *    software provided in binary form under this 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 HEREBY
- * 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; DAMAGE TO ANY DEVICE, 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. SOME STATES DO NOT ALLOW
- * THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE
- * ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
- * 
- */
-#include "crc.h"
-#include "compiler_abstraction.h"
-
-
-/**@brief Function for updating the current CRC-16 value for a single byte input.
- *
- * @param[in] current_crc The current calculated CRC-16 value.
- * @param[in] byte        The input data byte for the computation.
- *
- * @return The updated CRC-16 value, based on the input supplied.
- */
-static __INLINE uint16_t crc16_get(uint16_t current_crc, uint8_t byte)
-{
-    static const uint16_t crc16_table[16] =
-    {
-        0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
-        0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
-    };
-
-    uint16_t temp;
-
-    // Compute checksum of lower four bits of a byte.
-    temp         = crc16_table[current_crc & 0xF];
-    current_crc  = (current_crc >> 4u) & 0x0FFFu;
-    current_crc  = current_crc ^ temp ^ crc16_table[byte & 0xF];
-
-    // Now compute checksum of upper four bits of a byte.
-    temp         = crc16_table[current_crc & 0xF];
-    current_crc  = (current_crc >> 4u) & 0x0FFFu;
-    current_crc  = current_crc ^ temp ^ crc16_table[(byte >> 4u) & 0xF];
-
-    return current_crc;
-}
-
-
-uint16_t crc_crc16_update(uint16_t current_crc, const volatile void * p_data, uint32_t size)
-{
-    uint8_t * p_block = (uint8_t *)p_data;
-
-    while (size != 0)
-    {
-        current_crc = crc16_get(current_crc, *p_block);
-        p_block++;
-        size--;
-    }
-
-   return current_crc;
-}

+ 0 - 94
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/crc.h

@@ -1,94 +0,0 @@
-/**
- * This software is subject to the ANT+ Shared Source License
- * www.thisisant.com/swlicenses
- * Copyright (c) Dynastream Innovations, Inc. 2012
- * 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 Dynastream nor the names of its
- *    contributors may be used to endorse or promote products
- *    derived from this software without specific prior
- *    written permission.
- * 
- * The following actions are prohibited:
- * 1) Redistribution of source code containing the ANT+ Network
- *    Key. The ANT+ Network Key is available to ANT+ Adopters.
- *    Please refer to http://thisisant.com to become an ANT+
- *    Adopter and access the key.
- * 
- * 2) Reverse engineering, decompilation, and/or disassembly of
- *    software provided in binary form under this 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 HEREBY
- * 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; DAMAGE TO ANY DEVICE, 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. SOME STATES DO NOT ALLOW
- * THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE
- * ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
- * 
- */
-/** @file
- * @brief The CRC-16 interface.
- * This file is based on implementation originally made by Dynastream Innovations Inc. - August 2012
- * @defgroup ant_fs_client_main ANT-FS client device simulator
- * @{
- * @ingroup ant_fs
- *
- * @brief The ANT-FS client device simulator.
- *
- */
-
-#ifndef CRC_H__
-#define CRC_H__
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Function for calculating CRC-16 in blocks.
- *
- * Feed each consecutive data block into this function, along with the current value of current_crc
- * as returned by the previous call of this function. The first call of this function should pass
- * the initial value (usually 0) of the crc in current_crc.
-
- * @param[in] current_crc The current calculated CRC-16 value.
- * @param[in] p_data      The input data block for computation.
- * @param[in] size        The size of the input data block in bytes.
- *
- * @return The updated CRC-16 value, based on the input supplied.
- */
-uint16_t crc_crc16_update(uint16_t current_crc, const volatile void * p_data, uint32_t size);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // CRC_H__
-
-/**
- *@}
- **/

+ 0 - 109
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_fs/defines.h

@@ -1,109 +0,0 @@
-/**
- * This software is subject to the ANT+ Shared Source License
- * www.thisisant.com/swlicenses
- * Copyright (c) Dynastream Innovations, Inc. 2012
- * 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 Dynastream nor the names of its
- *    contributors may be used to endorse or promote products
- *    derived from this software without specific prior
- *    written permission.
- * 
- * The following actions are prohibited:
- * 1) Redistribution of source code containing the ANT+ Network
- *    Key. The ANT+ Network Key is available to ANT+ Adopters.
- *    Please refer to http://thisisant.com to become an ANT+
- *    Adopter and access the key.
- * 
- * 2) Reverse engineering, decompilation, and/or disassembly of
- *    software provided in binary form under this 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 HEREBY
- * 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; DAMAGE TO ANY DEVICE, 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. SOME STATES DO NOT ALLOW
- * THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE
- * ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
- * 
- */
-/**@file
- * @brief Definitions.
- * This file is based on implementation originally made by Dynastream Innovations Inc. - August 2012
- * @defgroup ant_fs_client_main ANT-FS client device simulator
- * @{
- * @ingroup nrf_ant_fs_client
- *
- * @brief The ANT-FS client device simulator.
- *
- */
-
-#ifndef DEFINES_H__
-#define DEFINES_H__
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MAX_ULONG 0xFFFFFFFFu                 /**< The Max value for the type. */
-
-/**@brief uint16_t type presentation as an union. */
-typedef union
-{
-    uint16_t data;                            /**< The data content. */
-
-    struct
-    {
-        uint8_t low;                          /**< The low byte of the data content. */
-        uint8_t high;                         /**< The high byte of the data content. */
-    } bytes;
-} ushort_union_t;
-
-/**@brief uint32_t type presentation as an union. */
-typedef union
-{
-    uint32_t data;                            /**< The data content as a single variable. */
-    uint8_t  data_bytes[sizeof(uint32_t)];    /**< The data content as a byte array. */
-
-    struct
-    {
-        // The least significant byte of the uint32_t in this structure is referenced by byte0.
-        uint8_t byte0;                        /**< Byte 0 of the data content. */
-        uint8_t byte1;                        /**< Byte 1 of the data content. */
-        uint8_t byte2;                        /**< Byte 2 of the data content. */
-        uint8_t byte3;                        /**< Byte 3 of the data content. */
-    } bytes;
-} ulong_union_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // DEFINES_H__
-
-/**
- *@}
- **/

+ 0 - 67
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_key_manager/ant_key_manager.c

@@ -1,67 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_KEY_MANAGER)
-#include <stdio.h>
-#include "ant_key_manager.h"
-#include "ant_key_manager_config.h"
-#include "ant_interface.h"
-#include "nrf_assert.h"
-
-static uint8_t m_ant_plus_network_key[] = ANT_PLUS_NETWORK_KEY;
-static uint8_t m_ant_fs_network_key[]   = ANT_FS_NETWORK_KEY;
-
-uint32_t ant_custom_key_set(uint8_t network_number, uint8_t * network_key)
-{
-    ASSERT(network_key != NULL);
-    return sd_ant_network_address_set(network_number, network_key);
-}
-
-uint32_t ant_plus_key_set(uint8_t network_number)
-{
-    return sd_ant_network_address_set(network_number, m_ant_plus_network_key);
-}
-
-uint32_t ant_fs_key_set(uint8_t network_number)
-{
-    return sd_ant_network_address_set(network_number, m_ant_fs_network_key);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_KEY_MANAGER)

+ 0 - 104
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_key_manager/ant_key_manager.h

@@ -1,104 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_KEY_MANAGER_H__
-#define ANT_KEY_MANAGER_H__
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @file
- */
-/**
- * @defgroup ant_key_manager ANT key manager
- * @{
- * @ingroup ant_sdk_utils
- * @brief Module for registering common and custom ANT network keys.
- */
-
-/**@brief Function for registering a custom network key.
- *
- * @param[in]  network_number   Network key number.
- * @param[in]  p_network_key    Pointer to the custom ANT network key.
- *
- * @return A SoftDevice error code.
- */
-uint32_t ant_custom_key_set(uint8_t network_number, uint8_t * p_network_key);
-
-/**@brief Function for registering an ANT+ network key.
- *
- * The key must be defined by @ref ANT_PLUS_NETWORK_KEY.
- *
- * @note The ANT+ Network Key is available for ANT+ Adopters. Go to http://thisisant.com
- *       to become an ANT+ Adopter and access the key.
- *
- * @param[in]  network_number   Network key number.
- *
- * @return A SoftDevice error code.
- */
-uint32_t ant_plus_key_set(uint8_t network_number);
-
-/**@brief Function for registering an ANT-FS network key.
- *
- * The key must be defined by @ref ANT_FS_NETWORK_KEY.
- *
- * @note The ANT+ Network Key is available for ANT+ Adopters. Go to http://thisisant.com
- *       to become an ANT+ Adopter and access the key.
- *
- * @param[in]  network_number   Network key number.
- *
- * @return A SoftDevice error code.
- */
-uint32_t ant_fs_key_set(uint8_t network_number);
-
-
-/**
- * @}
- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_KEY_MANAGER_H__

+ 0 - 69
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_key_manager/config/ant_key_manager_config.h

@@ -1,69 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_KEY_MANAGER_CONFIG_H__
-#define ANT_KEY_MANAGER_CONFIG_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup ant_key_manager
- * @{
- */
-
-#ifndef ANT_PLUS_NETWORK_KEY
-    #define ANT_PLUS_NETWORK_KEY    {0, 0, 0, 0, 0, 0, 0, 0}            /**< The ANT+ network key. */
-#endif //ANT_PLUS_NETWORK_KEY
-
-#ifndef ANT_FS_NETWORK_KEY
-    #define ANT_FS_NETWORK_KEY      {0, 0, 0, 0, 0, 0, 0, 0}           /**< The ANT-FS network key. */
-#endif // ANT_FS_NETWORK_KEY
-
-/**
- * @}
- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_KEY_MANAGER_CONFIG_H__

+ 0 - 491
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/ant_bpwr.c

@@ -1,491 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BPWR)
-
-#include "nrf_assert.h"
-#include "app_error.h"
-#include "ant_interface.h"
-#include "ant_bpwr.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BPWR"
-#if ANT_BPWR_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BPWR_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BPWR_INFO_COLOR
-#else // ANT_BPWR_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BPWR_LOG_ENABLED
-#include "nrf_log.h"
-
-#define BPWR_CALIB_INT_TIMEOUT ((ANT_CLOCK_FREQUENCY * BPWR_CALIBRATION_TIMOUT_S) / BPWR_MSG_PERIOD) // calibration timeout in ant message period's unit
-
-// for torque sensor Minimum: Interleave every 9th message
-#define BPWR_PAGE_16_INTERVAL      5   // Preferred: Interleave every 5th message
-#define BPWR_PAGE_16_INTERVAL_OFS  2   // Permissible offset
-#define COMMON_PAGE_80_INTERVAL    119 // Minimum: Interleave every 121 messages
-#define COMMON_PAGE_81_INTERVAL    120 // Minimum: Interleave every 121 messages
-#define AUTO_ZERO_SUPPORT_INTERVAL 120 // Minimum: Interleave every 121 messages
-
-/**@brief Bicycle power message data layout structure. */
-typedef struct
-{
-    uint8_t page_number;
-    uint8_t page_payload[7];
-} ant_bpwr_message_layout_t;
-
-
-/**@brief Function for initializing the ANT Bicycle Power Profile instance.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- * @param[in]  p_channel_config Pointer to the ANT channel configuration structure.
- *
- * @retval     NRF_SUCCESS      If initialization was successful. Otherwise, an error code is returned.
- */
-static ret_code_t ant_bpwr_init(ant_bpwr_profile_t         * p_profile,
-                                ant_channel_config_t const * p_channel_config)
-{
-    p_profile->channel_number = p_channel_config->channel_number;
-
-    p_profile->page_1  = DEFAULT_ANT_BPWR_PAGE1();
-    p_profile->page_16 = DEFAULT_ANT_BPWR_PAGE16();
-    p_profile->page_17 = DEFAULT_ANT_BPWR_PAGE17();
-    p_profile->page_18 = DEFAULT_ANT_BPWR_PAGE18();
-    p_profile->page_80 = DEFAULT_ANT_COMMON_page80();
-    p_profile->page_81 = DEFAULT_ANT_COMMON_page81();
-
-    NRF_LOG_INFO("ANT B-PWR channel %u init\r\n", p_profile->channel_number);
-    return ant_channel_init(p_channel_config);
-}
-
-
-ret_code_t ant_bpwr_disp_init(ant_bpwr_profile_t           * p_profile,
-                              ant_channel_config_t const   * p_channel_config,
-                              ant_bpwr_disp_config_t const * p_disp_config)
-{
-    ASSERT(p_profile != NULL);
-    ASSERT(p_channel_config != NULL);
-    ASSERT(p_disp_config != NULL);
-    ASSERT(p_disp_config->evt_handler != NULL);
-    ASSERT(p_disp_config->p_cb != NULL);
-
-    p_profile->evt_handler   = p_disp_config->evt_handler;
-    p_profile->_cb.p_disp_cb = p_disp_config->p_cb;
-
-    p_profile->_cb.p_disp_cb ->calib_timeout = 0;
-    p_profile->_cb.p_disp_cb ->calib_stat    = BPWR_DISP_CALIB_NONE;
-
-    return ant_bpwr_init(p_profile, p_channel_config);
-}
-
-
-ret_code_t ant_bpwr_sens_init(ant_bpwr_profile_t           * p_profile,
-                              ant_channel_config_t const   * p_channel_config,
-                              ant_bpwr_sens_config_t const * p_sens_config)
-{
-    ASSERT(p_profile != NULL);
-    ASSERT(p_channel_config != NULL);
-    ASSERT(p_sens_config != NULL);
-    ASSERT(p_sens_config->p_cb != NULL);
-    ASSERT(p_sens_config->evt_handler != NULL);
-    ASSERT(p_sens_config->calib_handler != NULL);
-
-    p_profile->evt_handler   = p_sens_config->evt_handler;
-    p_profile->_cb.p_sens_cb = p_sens_config->p_cb;
-
-    p_profile->_cb.p_sens_cb->torque_use      = p_sens_config->torque_use;
-    p_profile->_cb.p_sens_cb->calib_handler   = p_sens_config->calib_handler;
-    p_profile->_cb.p_sens_cb->calib_stat      = BPWR_SENS_CALIB_NONE;
-    p_profile->_cb.p_sens_cb->message_counter = 0;
-
-    return ant_bpwr_init(p_profile, p_channel_config);
-}
-
-
-
-/**@brief Function for getting next page number to send.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- *
- * @return     Next page number.
- */
-static ant_bpwr_page_t next_page_number_get(ant_bpwr_profile_t * p_profile)
-{
-    ant_bpwr_sens_cb_t * p_bpwr_cb = p_profile->_cb.p_sens_cb;
-    ant_bpwr_page_t      page_number;
-
-    if (p_bpwr_cb->calib_stat == BPWR_SENS_CALIB_READY)
-    {
-        page_number           = ANT_BPWR_PAGE_1;
-        p_bpwr_cb->calib_stat = BPWR_SENS_CALIB_NONE; // mark event as processed
-    }
-    else if ((p_profile->BPWR_PROFILE_auto_zero_status != ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED)
-             && (p_bpwr_cb->message_counter == AUTO_ZERO_SUPPORT_INTERVAL))
-    {
-        page_number                            = ANT_BPWR_PAGE_1;
-        p_profile->BPWR_PROFILE_calibration_id = ANT_BPWR_CALIB_ID_AUTO_SUPPORT;
-        p_bpwr_cb->message_counter++;
-    }
-    else if (p_bpwr_cb->message_counter >= COMMON_PAGE_81_INTERVAL)
-    {
-        page_number                = ANT_BPWR_PAGE_81;
-        p_bpwr_cb->message_counter = 0;
-    }
-    else
-    {
-        if (p_bpwr_cb->message_counter == COMMON_PAGE_80_INTERVAL)
-        {
-            page_number = ANT_BPWR_PAGE_80;
-        }
-        else
-        {
-            if ( p_bpwr_cb->torque_use == TORQUE_NONE)
-            {
-                page_number = ANT_BPWR_PAGE_16;
-            }
-            else if ((p_bpwr_cb->message_counter % BPWR_PAGE_16_INTERVAL)
-                     == BPWR_PAGE_16_INTERVAL_OFS)
-            {
-                page_number = ANT_BPWR_PAGE_16;
-            }
-            else if ( p_bpwr_cb->torque_use == TORQUE_WHEEL)
-            {
-                page_number = ANT_BPWR_PAGE_17;
-            }
-            else // assumed TORQUE_CRANK
-            {
-                page_number = ANT_BPWR_PAGE_18;
-            }
-        }
-        p_bpwr_cb->message_counter++;
-    }
-
-    return page_number;
-}
-
-
-/**@brief Function for encoding Bicycle Power Sensor message.
- *
- * @note Assume to be call each time when Tx window will occur.
- */
-static void sens_message_encode(ant_bpwr_profile_t * p_profile, uint8_t * p_message_payload)
-{
-    ant_bpwr_message_layout_t * p_bpwr_message_payload =
-        (ant_bpwr_message_layout_t *)p_message_payload;
-
-    p_bpwr_message_payload->page_number = next_page_number_get(p_profile);
-
-    NRF_LOG_INFO("B-PWR tx page: %u\r\n", p_bpwr_message_payload->page_number);
-
-    switch (p_bpwr_message_payload->page_number)
-    {
-        case ANT_BPWR_PAGE_1:
-            ant_bpwr_page_1_encode(p_bpwr_message_payload->page_payload, &(p_profile->page_1));
-            break;
-
-        case ANT_BPWR_PAGE_16:
-            ant_bpwr_page_16_encode(p_bpwr_message_payload->page_payload, &(p_profile->page_16));
-            ant_bpwr_cadence_encode(p_bpwr_message_payload->page_payload, &(p_profile->common));
-            break;
-
-        case ANT_BPWR_PAGE_17:
-            ant_bpwr_page_17_encode(p_bpwr_message_payload->page_payload, &(p_profile->page_17));
-            ant_bpwr_cadence_encode(p_bpwr_message_payload->page_payload, &(p_profile->common));
-            break;
-
-        case ANT_BPWR_PAGE_18:
-            ant_bpwr_page_18_encode(p_bpwr_message_payload->page_payload, &(p_profile->page_18));
-            ant_bpwr_cadence_encode(p_bpwr_message_payload->page_payload, &(p_profile->common));
-            break;
-
-        case ANT_COMMON_PAGE_80:
-            ant_common_page_80_encode(p_bpwr_message_payload->page_payload, &(p_profile->page_80));
-            break;
-
-        case ANT_COMMON_PAGE_81:
-            ant_common_page_81_encode(p_bpwr_message_payload->page_payload, &(p_profile->page_81));
-            break;
-
-        default:
-            return;
-    }
-
-    p_profile->evt_handler(p_profile, (ant_bpwr_evt_t)p_bpwr_message_payload->page_number);
-
-}
-
-
-/**@brief Function for decoding messages received by Bicycle Power sensor message.
- *
- * @note Assume to be call each time when Rx window will occur.
- */
-static void sens_message_decode(ant_bpwr_profile_t * p_profile, uint8_t * p_message_payload)
-{
-    const ant_bpwr_message_layout_t * p_bpwr_message_payload =
-        (ant_bpwr_message_layout_t *)p_message_payload;
-    ant_bpwr_page1_data_t page1;
-
-    switch (p_bpwr_message_payload->page_number)
-    {
-        case ANT_BPWR_PAGE_1:
-            ant_bpwr_page_1_decode(p_bpwr_message_payload->page_payload, &page1);
-            p_profile->_cb.p_sens_cb->calib_stat = BPWR_SENS_CALIB_REQUESTED;
-            p_profile->_cb.p_sens_cb->calib_handler(p_profile, &page1);
-            break;
-
-        default:
-            break;
-    }
-}
-
-
-/**@brief Function for decoding messages received by Bicycle Power display message.
- *
- * @note Assume to be call each time when Rx window will occur.
- */
-static void disp_message_decode(ant_bpwr_profile_t * p_profile, uint8_t * p_message_payload)
-{
-    const ant_bpwr_message_layout_t * p_bpwr_message_payload =
-        (ant_bpwr_message_layout_t *)p_message_payload;
-
-    NRF_LOG_INFO("B-PWR rx page: %u\r\n", p_bpwr_message_payload->page_number);
-
-    switch (p_bpwr_message_payload->page_number)
-    {
-        case ANT_BPWR_PAGE_1:
-            ant_bpwr_page_1_decode(p_bpwr_message_payload->page_payload, &(p_profile->page_1));
-            p_profile->_cb.p_disp_cb->calib_stat = BPWR_DISP_CALIB_NONE;
-            break;
-
-        case ANT_BPWR_PAGE_16:
-            ant_bpwr_page_16_decode(p_bpwr_message_payload->page_payload, &(p_profile->page_16));
-            ant_bpwr_cadence_decode(p_bpwr_message_payload->page_payload, &(p_profile->common));
-            break;
-
-        case ANT_BPWR_PAGE_17:
-            ant_bpwr_page_17_decode(p_bpwr_message_payload->page_payload, &(p_profile->page_17));
-            ant_bpwr_cadence_decode(p_bpwr_message_payload->page_payload, &(p_profile->common));
-            break;
-
-        case ANT_BPWR_PAGE_18:
-            ant_bpwr_page_18_decode(p_bpwr_message_payload->page_payload, &(p_profile->page_18));
-            ant_bpwr_cadence_decode(p_bpwr_message_payload->page_payload, &(p_profile->common));
-            break;
-
-        case ANT_COMMON_PAGE_80:
-            ant_common_page_80_decode(p_bpwr_message_payload->page_payload, &(p_profile->page_80));
-            break;
-
-        case ANT_COMMON_PAGE_81:
-            ant_common_page_81_decode(p_bpwr_message_payload->page_payload, &(p_profile->page_81));
-            break;
-
-        default:
-            return;
-    }
-
-    p_profile->evt_handler(p_profile, (ant_bpwr_evt_t)p_bpwr_message_payload->page_number);
-}
-
-
-ret_code_t ant_bpwr_calib_request(ant_bpwr_profile_t * p_profile, ant_bpwr_page1_data_t * p_page_1)
-{
-    ant_bpwr_message_layout_t bpwr_message_payload;
-
-    if (p_profile->_cb.p_disp_cb->calib_stat == BPWR_DISP_CALIB_REQUESTED)
-    {
-        return NRF_SUCCESS; // calibration in progress, so omit this request
-    }
-
-    bpwr_message_payload.page_number = ANT_BPWR_PAGE_1;
-    ant_bpwr_page_1_encode(bpwr_message_payload.page_payload, p_page_1);
-
-    uint32_t err_code = sd_ant_acknowledge_message_tx(p_profile->channel_number,
-                                                      sizeof (bpwr_message_payload),
-                                                      (uint8_t *) &bpwr_message_payload);
-
-    if (err_code == NRF_SUCCESS)
-    {
-        p_profile->_cb.p_disp_cb->calib_timeout = BPWR_CALIB_INT_TIMEOUT; // initialize watch on calibration's time-out
-        p_profile->_cb.p_disp_cb->calib_stat    = BPWR_DISP_CALIB_REQUESTED;
-        NRF_LOG_INFO("Start calibration process\r\n");
-    }
-    return err_code;
-}
-
-
-void ant_bpwr_calib_response(ant_bpwr_profile_t * p_profile)
-{
-    if (p_profile->_cb.p_sens_cb->calib_stat != BPWR_SENS_CALIB_READY) // abort if callback request is in progress
-    {
-        p_profile->_cb.p_sens_cb->calib_stat = BPWR_SENS_CALIB_READY; // calibration respond
-    }
-}
-
-
-/**@brief Function for hangling calibration events.
- */
-static void service_calib(ant_bpwr_profile_t * p_profile, uint8_t event)
-{
-    ant_bpwr_evt_t       bpwr_event;
-
-    if (p_profile->_cb.p_disp_cb->calib_stat == BPWR_DISP_CALIB_REQUESTED)
-    {
-        switch (event)
-        {
-            case EVENT_RX:
-            /* fall through */
-            case EVENT_RX_FAIL:
-
-                if (p_profile->_cb.p_disp_cb->calib_timeout-- == 0)
-                {
-                    bpwr_event = ANT_BPWR_CALIB_TIMEOUT;
-                    break;
-                }
-                else
-                {
-                    return;
-                }
-
-            case EVENT_TRANSFER_TX_FAILED:
-                bpwr_event = ANT_BPWR_CALIB_REQUEST_TX_FAILED;
-                break;
-
-            case EVENT_RX_SEARCH_TIMEOUT:
-                bpwr_event = ANT_BPWR_CALIB_TIMEOUT;
-                break;
-
-            default:
-                return;
-        }
-
-        NRF_LOG_INFO("End calibration process\r\n");
-        p_profile->_cb.p_disp_cb->calib_stat = BPWR_DISP_CALIB_NONE;
-
-        p_profile->evt_handler(p_profile, bpwr_event);
-    }
-}
-
-
-static void ant_message_send(ant_bpwr_profile_t * p_profile)
-{
-    uint32_t err_code;
-    uint8_t  p_message_payload[ANT_STANDARD_DATA_PAYLOAD_SIZE];
-
-    sens_message_encode(p_profile, p_message_payload);
-    err_code =
-        sd_ant_broadcast_message_tx(p_profile->channel_number,
-                                    sizeof (p_message_payload),
-                                    p_message_payload);
-    APP_ERROR_CHECK(err_code);
-}
-
-
-ret_code_t ant_bpwr_disp_open(ant_bpwr_profile_t * p_profile)
-{
-    NRF_LOG_INFO("ANT B-PWR %u open\r\n", p_profile->channel_number);
-    return sd_ant_channel_open(p_profile->channel_number);
-}
-
-
-ret_code_t ant_bpwr_sens_open(ant_bpwr_profile_t * p_profile)
-{
-    // Fill tx buffer for the first frame
-    ant_message_send(p_profile);
-
-    NRF_LOG_INFO("ANT B-PWR %u open\r\n", p_profile->channel_number);
-    return sd_ant_channel_open(p_profile->channel_number);
-}
-
-
-void ant_bpwr_sens_evt_handler(ant_bpwr_profile_t * p_profile, ant_evt_t * p_ant_event)
-{
-    if (p_ant_event->channel == p_profile->channel_number)
-    {
-        ANT_MESSAGE * p_message;
-
-        switch (p_ant_event->event)
-        {
-            case EVENT_TX:
-                ant_message_send(p_profile);
-                break;
-
-            case EVENT_RX:
-                p_message = (ANT_MESSAGE *)p_ant_event->msg.evt_buffer;
-
-                if (p_message->ANT_MESSAGE_ucMesgID == MESG_ACKNOWLEDGED_DATA_ID)
-                {
-                    sens_message_decode(p_profile, p_message->ANT_MESSAGE_aucPayload);
-                }
-                break;
-
-            default:
-                // No implementation needed
-                break;
-        }
-    }
-}
-
-
-void ant_bpwr_disp_evt_handler(ant_bpwr_profile_t * p_profile, ant_evt_t * p_ant_event)
-{
-    if (p_ant_event->channel == p_profile->channel_number)
-    {
-        ANT_MESSAGE * p_message = (ANT_MESSAGE *)p_ant_event->msg.evt_buffer;
-
-        switch (p_ant_event->event)
-        {
-            case EVENT_RX:
-
-                if (p_message->ANT_MESSAGE_ucMesgID == MESG_BROADCAST_DATA_ID
-                    || p_message->ANT_MESSAGE_ucMesgID == MESG_ACKNOWLEDGED_DATA_ID
-                    || p_message->ANT_MESSAGE_ucMesgID == MESG_BURST_DATA_ID)
-                {
-                    disp_message_decode(p_profile, p_message->ANT_MESSAGE_aucPayload);
-                }
-                break;
-
-            default:
-                break;
-        }
-        service_calib(p_profile, p_ant_event->event);
-    }
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BPWR)

+ 0 - 374
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/ant_bpwr.h

@@ -1,374 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-/**
- * @file
- * @defgroup ant_bpwr Bicycle Power profile
- * @{
- * @ingroup ant_sdk_profiles
- * @brief This module implements the Bicycle Power profile.
- *
- */
-
- #ifndef ANT_BICYCLE_POWER_H__
- #define ANT_BICYCLE_POWER_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "ant_parameters.h"
-#include "ant_stack_handler_types.h"
-#include "ant_channel_config.h"
-#include "ant_bpwr_pages.h"
-#include "sdk_errors.h"
-
-#define BPWR_DEVICE_TYPE            0x0Bu               ///< Device type reserved for ANT+ Bicycle Power.
-#define BPWR_ANTPLUS_RF_FREQ        0x39u               ///< Frequency, decimal 57 (2457 MHz).
-#define BPWR_MSG_PERIOD             8182u               ///< Message period, decimal 8182 (4.0049 Hz).
-
-#define BPWR_EXT_ASSIGN             0x00                ///< ANT ext assign (see Ext. Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
-#define BPWR_DISP_CHANNEL_TYPE      CHANNEL_TYPE_SLAVE  ///< Display Bicycle Power channel type.
-#define BPWR_SENS_CHANNEL_TYPE      CHANNEL_TYPE_MASTER ///< Sensor Bicycle Power channel type.
-
-#define BPWR_CALIBRATION_TIMOUT_S   5u                  ///< Time-out for responding to calibration callback (s).
-
-/**@brief Initialize an ANT channel configuration structure for the Bicycle Power profile (Display).
- *
- * @param[in]  NAME                 Name of related instance.
- * @param[in]  CHANNEL_NUMBER       Number of the channel assigned to the profile instance.
- * @param[in]  TRANSMISSION_TYPE    Type of transmission assigned to the profile instance.
- * @param[in]  DEVICE_NUMBER        Number of the device assigned to the profile instance.
- * @param[in]  NETWORK_NUMBER       Number of the network assigned to the profile instance.
- */
-#define BPWR_DISP_CHANNEL_CONFIG_DEF(NAME,                              \
-                                     CHANNEL_NUMBER,                    \
-                                     TRANSMISSION_TYPE,                 \
-                                     DEVICE_NUMBER,                     \
-                                     NETWORK_NUMBER)                    \
-static const ant_channel_config_t   NAME##_channel_bpwr_disp_config =   \
-    {                                                                   \
-        .channel_number    = (CHANNEL_NUMBER),                          \
-        .channel_type      = BPWR_DISP_CHANNEL_TYPE,                    \
-        .ext_assign        = BPWR_EXT_ASSIGN,                           \
-        .rf_freq           = BPWR_ANTPLUS_RF_FREQ,                      \
-        .transmission_type = (TRANSMISSION_TYPE),                       \
-        .device_type       = BPWR_DEVICE_TYPE,                          \
-        .device_number     = (DEVICE_NUMBER),                           \
-        .channel_period    = BPWR_MSG_PERIOD,                           \
-        .network_number    = (NETWORK_NUMBER),                          \
-    }
-#define BPWR_DISP_CHANNEL_CONFIG(NAME) &NAME##_channel_bpwr_disp_config
-
-/**@brief Initialize an ANT channel configuration structure for the Bicycle Power profile (Sensor).
- *
- * @param[in]  NAME                 Name of related instance.
- * @param[in]  CHANNEL_NUMBER       Number of the channel assigned to the profile instance.
- * @param[in]  TRANSMISSION_TYPE    Type of transmission assigned to the profile instance.
- * @param[in]  DEVICE_NUMBER        Number of the device assigned to the profile instance.
- * @param[in]  NETWORK_NUMBER       Number of the network assigned to the profile instance.
- */
-#define BPWR_SENS_CHANNEL_CONFIG_DEF(NAME,                              \
-                                     CHANNEL_NUMBER,                    \
-                                     TRANSMISSION_TYPE,                 \
-                                     DEVICE_NUMBER,                     \
-                                     NETWORK_NUMBER)                    \
-static const ant_channel_config_t   NAME##_channel_bpwr_sens_config =   \
-    {                                                                   \
-        .channel_number    = (CHANNEL_NUMBER),                          \
-        .channel_type      = BPWR_SENS_CHANNEL_TYPE,                    \
-        .ext_assign        = BPWR_EXT_ASSIGN,                           \
-        .rf_freq           = BPWR_ANTPLUS_RF_FREQ,                      \
-        .transmission_type = (TRANSMISSION_TYPE),                       \
-        .device_type       = BPWR_DEVICE_TYPE,                          \
-        .device_number     = (DEVICE_NUMBER),                           \
-        .channel_period    = BPWR_MSG_PERIOD,                           \
-        .network_number    = (NETWORK_NUMBER),                          \
-    }
-#define BPWR_SENS_CHANNEL_CONFIG(NAME) &NAME##_channel_bpwr_sens_config
-
-/**@brief Initialize an ANT profile configuration structure for the BPWR profile (Display).
- *
- * @param[in]  NAME                 Name of related instance.
- * @param[in]  EVT_HANDLER          Event handler to be called for handling events in the BPWR profile.
- */
-#define BPWR_DISP_PROFILE_CONFIG_DEF(NAME,                              \
-                                     EVT_HANDLER)                       \
-static ant_bpwr_disp_cb_t            NAME##_bpwr_disp_cb;               \
-static const ant_bpwr_disp_config_t  NAME##_profile_bpwr_disp_config =  \
-    {                                                                   \
-        .p_cb               = &NAME##_bpwr_disp_cb,                     \
-        .evt_handler        = (EVT_HANDLER),                            \
-    }
-#define BPWR_DISP_PROFILE_CONFIG(NAME) &NAME##_profile_bpwr_disp_config
-
-/**@brief Initialize an ANT profile configuration structure for the BPWR profile (Sensor).
- *
- * @param[in]  NAME                 Name of related instance.
- * @param[in]  TORQUE_USED          Determines whether the torque page is included.
- * @param[in]  CALIB_HANDLER        Event handler to be called for handling calibration requests.
- * @param[in]  EVT_HANDLER          Event handler to be called for handling events in the BPWR profile.
- */
-#define BPWR_SENS_PROFILE_CONFIG_DEF(NAME,                              \
-                                     TORQUE_USED,                       \
-                                     CALIB_HANDLER,                     \
-                                     EVT_HANDLER)                       \
-static ant_bpwr_sens_cb_t            NAME##_bpwr_sens_cb;               \
-static const ant_bpwr_sens_config_t  NAME##_profile_bpwr_sens_config =  \
-    {                                                                   \
-        .torque_use         = (TORQUE_USED),                            \
-        .calib_handler      = (CALIB_HANDLER),                          \
-        .p_cb               = &NAME##_bpwr_sens_cb,                     \
-        .evt_handler        = (EVT_HANDLER),                            \
-    }
-#define BPWR_SENS_PROFILE_CONFIG(NAME) &NAME##_profile_bpwr_sens_config
-
-/**@brief Configuration values for the Bicycle Power torque page. */
-typedef enum
-{
-    TORQUE_NONE  = 0,
-    TORQUE_WHEEL = 1,
-    TORQUE_CRANK = 2,
-} ant_bpwr_torque_t;
-
-/**@brief Bicycle Power page number type. */
-typedef enum
-{
-    ANT_BPWR_PAGE_1  = 1,  ///< Calibration data page.
-    ANT_BPWR_PAGE_16 = 16, ///< Standard power-only main data page.
-    ANT_BPWR_PAGE_17 = 17, ///< Standard wheel torque main data page.
-    ANT_BPWR_PAGE_18 = 18, ///< Standard crank torque main data page.
-    ANT_BPWR_PAGE_80 = ANT_COMMON_PAGE_80,
-    ANT_BPWR_PAGE_81 = ANT_COMMON_PAGE_81
-} ant_bpwr_page_t;
-
-/**@brief BPWR profile event type. */
-typedef enum
-{
-    ANT_BPWR_PAGE_1_UPDATED  = ANT_BPWR_PAGE_1,  ///< Data page 1 and speed have been updated (Display) or sent (Sensor).
-    ANT_BPWR_PAGE_16_UPDATED = ANT_BPWR_PAGE_16, ///< Data page 16 and speed have been updated (Display) or sent (Sensor).
-    ANT_BPWR_PAGE_17_UPDATED = ANT_BPWR_PAGE_17, ///< Data page 17 and speed have been updated (Display) or sent (Sensor).
-    ANT_BPWR_PAGE_18_UPDATED = ANT_BPWR_PAGE_18, ///< Data page 18 has been updated (Display) or sent (Sensor).
-    ANT_BPWR_PAGE_80_UPDATED = ANT_BPWR_PAGE_80, ///< Data page 80 has been updated (Display) or sent (Sensor).
-    ANT_BPWR_PAGE_81_UPDATED = ANT_BPWR_PAGE_81, ///< Data page 81 has been updated (Display) or sent (Sensor).
-    ANT_BPWR_CALIB_TIMEOUT,                      ///< Request of calibration time-out occurred (Display).
-    ANT_BPWR_CALIB_REQUEST_TX_FAILED,            ///< Calibration request did not reach the destination (Display).
-} ant_bpwr_evt_t;
-
-// Forward declaration of the ant_bpwr_profile_t type.
-typedef struct ant_bpwr_profile_s ant_bpwr_profile_t;
-
-/**@brief BPWR event handler type. */
-typedef void (* ant_bpwr_evt_handler_t) (ant_bpwr_profile_t *, ant_bpwr_evt_t);
-
-/**@brief BPWR Sensor calibration request handler type. */
-typedef void (* ant_bpwr_calib_handler_t) (ant_bpwr_profile_t *, ant_bpwr_page1_data_t *);
-
-#include "ant_bpwr_local.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Bicycle Power Sensor configuration structure. */
-typedef struct
-{
-    ant_bpwr_torque_t        torque_use;    ///< Determines whether the torque page is included.
-    ant_bpwr_sens_cb_t     * p_cb;          ///< Pointer to the data buffer for internal use.
-    ant_bpwr_evt_handler_t   evt_handler;   ///< Event handler to be called for handling events in the BPWR profile.
-    ant_bpwr_calib_handler_t calib_handler; ///< Event handler to be called for handling calibration requests.
-} ant_bpwr_sens_config_t;
-
-/**@brief Bicycle Power Display configuration structure. */
-typedef struct
-{
-    ant_bpwr_disp_cb_t   * p_cb;            ///< Pointer to the data buffer for internal use.
-    ant_bpwr_evt_handler_t evt_handler;     ///< Event handler to be called for handling events in the BPWR profile.
-} ant_bpwr_disp_config_t;
-
-/**@brief Bicycle Power profile structure. */
-struct ant_bpwr_profile_s
-{
-    uint8_t                  channel_number; ///< Channel number assigned to the profile.
-    union {
-        ant_bpwr_disp_cb_t * p_disp_cb;
-        ant_bpwr_sens_cb_t * p_sens_cb;
-    } _cb;                                ///< Pointer to internal control block.
-    ant_bpwr_evt_handler_t   evt_handler;    ///< Event handler to be called for handling events in the BPWR profile.
-    ant_bpwr_page1_data_t    page_1;         ///< Page 1.
-    ant_bpwr_page16_data_t   page_16;        ///< Page 16.
-    ant_bpwr_page17_data_t   page_17;        ///< Page 17.
-    ant_bpwr_page18_data_t   page_18;        ///< Page 18.
-    ant_common_page80_data_t page_80;        ///< Page 80.
-    ant_common_page81_data_t page_81;        ///< Page 81.
-    ant_bpwr_common_data_t   common;         ///< BPWR common data.
-};
-
-/** @name Defines for accessing ant_bpwr_profile_t member variables
-   @{ */
-#define BPWR_PROFILE_calibration_id              page_1.calibration_id
-#define BPWR_PROFILE_auto_zero_status            page_1.auto_zero_status
-#define BPWR_PROFILE_general_calib_data          page_1.data.general_calib
-#define BPWR_PROFILE_custom_calib_data           page_1.data.custom_calib
-#define BPWR_PROFILE_instantaneous_cadence       common.instantaneous_cadence
-#define BPWR_PROFILE_pedal_power                 page_16.pedal_power.items
-#define BPWR_PROFILE_power_update_event_count    page_16.update_event_count
-#define BPWR_PROFILE_accumulated_power           page_16.accumulated_power
-#define BPWR_PROFILE_instantaneous_power         page_16.instantaneous_power
-#define BPWR_PROFILE_wheel_update_event_count    page_17.update_event_count
-#define BPWR_PROFILE_wheel_tick                  page_17.tick
-#define BPWR_PROFILE_wheel_period                page_17.period
-#define BPWR_PROFILE_wheel_accumulated_torque    page_17.accumulated_torque
-#define BPWR_PROFILE_crank_update_event_count    page_18.update_event_count
-#define BPWR_PROFILE_crank_tick                  page_18.tick
-#define BPWR_PROFILE_crank_period                page_18.period
-#define BPWR_PROFILE_crank_accumulated_torque    page_18.accumulated_torque
-#define BPWR_PROFILE_manuf_id                    page_80.manuf_id
-#define BPWR_PROFILE_hw_revision                 page_80.hw_revision
-#define BPWR_PROFILE_manufacturer_id             page_80.manufacturer_id
-#define BPWR_PROFILE_model_number                page_80.model_number
-#define BPWR_PROFILE_sw_revision_minor           page_81.sw_revision_minor
-#define BPWR_PROFILE_sw_revision_major           page_81.sw_revision_major
-#define BPWR_PROFILE_serial_number               page_81.serial_number
-/** @} */
-
-/**@brief Function for initializing the ANT Bicycle Power Display profile instance.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- * @param[in]  p_channel_config Pointer to the ANT channel configuration structure.
- * @param[in]  p_disp_config    Pointer to the Bicycle Power Display configuration structure.
- *
- * @retval     NRF_SUCCESS      If initialization was successful. Otherwise, an error code is returned.
- */
-ret_code_t ant_bpwr_disp_init(ant_bpwr_profile_t           * p_profile,
-                              ant_channel_config_t const   * p_channel_config,
-                              ant_bpwr_disp_config_t const * p_disp_config);
-
-/**@brief Function for initializing the ANT Bicycle Power Sensor profile instance.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- * @param[in]  p_channel_config Pointer to the ANT channel configuration structure.
- * @param[in]  p_sens_config    Pointer to the Bicycle Power Sensor configuration structure.
- *
- * @retval     NRF_SUCCESS      If initialization was successful. Otherwise, an error code is returned.
- */
-ret_code_t ant_bpwr_sens_init(ant_bpwr_profile_t           * p_profile,
-                              ant_channel_config_t const   * p_channel_config,
-                              ant_bpwr_sens_config_t const * p_sens_config);
-
-/**@brief Function for opening the profile instance channel for ANT BPWR Display.
- *
- * Before calling this function, pages should be configured.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- *
- * @retval     NRF_SUCCESS      If the channel was successfully opened. Otherwise, an error code is returned.
- */
-ret_code_t ant_bpwr_disp_open(ant_bpwr_profile_t * p_profile);
-
-/**@brief Function for opening the profile instance channel for ANT BPWR Sensor.
- *
- * Before calling this function, pages should be configured.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- *
- * @retval     NRF_SUCCESS      If the channel was successfully opened. Otherwise, an error code is returned.
- */
-ret_code_t ant_bpwr_sens_open(ant_bpwr_profile_t * p_profile);
-
-/** @name Functions: Sensor calibration API
- * @{
- */
-
-/** @brief Function for initializing the response for a calibration request.
- *
- *  This function should be used to signal the status of the calibration procedure to the ANT profile layer .
- *
- *  @param[in] p_profile   Pointer to the profile instance.
- */
-void ant_bpwr_calib_response(ant_bpwr_profile_t * p_profile);
-/** @} */
-
-
-/**@brief Function for handling the Sensor ANT events.
- *
- * @details This function handles all events from the ANT stack that are of interest to the Bicycle Power Display profile.
- *
- * @param[in]   p_profile       Pointer to the profile instance.
- * @param[in]   p_ant_event     Event received from the ANT stack.
- */
-void ant_bpwr_sens_evt_handler(ant_bpwr_profile_t * p_profile, ant_evt_t * p_ant_event);
-
-/**@brief Function for handling the Display ANT events.
- *
- * @details This function handles all events from the ANT stack that are of interest to the Bicycle Power Display profile.
- *
- * @param[in]   p_profile       Pointer to the profile instance.
- * @param[in]   p_ant_event     Event received from the ANT stack.
- */
-void ant_bpwr_disp_evt_handler(ant_bpwr_profile_t * p_profile, ant_evt_t * p_ant_event);
-
-/** @name Functions: Display calibration API
- * @{
- */
-
-/**@brief Function for initializing the calibration request process from the Bicycle Power Display side.
- *
- * @details This function requests a transfer to the Sensor and starts watching for the calibration response.
- * If a calibration response has already been requested, the function ignores the new request and returns NRF_SUCCESS.
- *
- * @param [in]   p_profile       Pointer to the profile instance.
- * @param [in]   p_page_1        Pointer to the prepared page 1.
- *
- * @return Values returned by the @ref sd_ant_acknowledge_message_tx SVC callback.
- */
-uint32_t ant_bpwr_calib_request(ant_bpwr_profile_t * p_profile, ant_bpwr_page1_data_t * p_page_1);
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BICYCLE_POWER_H__
-

+ 0 - 89
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/ant_bpwr_local.h

@@ -1,89 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_LOCAL_H__
-#define ANT_BPWR_LOCAL_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "ant_bpwr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup ant_bpwr
- * @{
- */
-
-/** @brief Bicycle Power Sensor control block. */
-typedef struct
-{
-    uint8_t           message_counter;
-    ant_bpwr_torque_t torque_use;
-    enum
-    {
-        BPWR_SENS_CALIB_NONE,      ///< Idle state.
-        BPWR_SENS_CALIB_REQUESTED, ///< Received request for general calibration result message by the sensor.
-        BPWR_SENS_CALIB_READY,     ///< Calibration response message is ready to be transmitted.
-    }                        calib_stat;
-    ant_bpwr_calib_handler_t calib_handler;
-} ant_bpwr_sens_cb_t;
-
-/**@brief Bicycle Power Sensor RX control block. */
-typedef struct
-{
-    uint8_t calib_timeout;
-    enum
-    {
-        BPWR_DISP_CALIB_NONE,      ///< Idle state.
-        BPWR_DISP_CALIB_REQUESTED, ///< Calibration requested.
-    } calib_stat;
-} ant_bpwr_disp_cb_t;
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_LOCAL_H__

+ 0 - 98
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_common_data.c

@@ -1,98 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BPWR)
-
-#include "ant_bpwr_common_data.h"
-#include "ant_bpwr_utils.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BPWR_COMMON"
-#if ANT_BPWR_COMMON_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BPWR_COMMON_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BPWR_COMMON_INFO_COLOR
-#else // ANT_BPWR_COMMON_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BPWR_COMMON_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief BPWR common page data layout structure. */
-typedef struct
-{
-    uint8_t reserved0[2];
-    uint8_t instantaneous_cadence;
-    uint8_t reserved1[4];
-}ant_bpwr_cadence_data_layout_t;
-
-/**@brief Function for tracing common data.
- *
- * @param[in]  p_common_data      Pointer to the common data.
- */
-static void cadence_data_log(ant_bpwr_common_data_t const * p_common_data)
-{
-    if (p_common_data->instantaneous_cadence == 0xFF)
-    {
-        NRF_LOG_INFO("instantaneous cadence:               -- rpm\r\n\n");
-    }
-    else
-    {
-        NRF_LOG_INFO("instantaneous cadence:               %u rpm\r\n\n",
-                    p_common_data->instantaneous_cadence);
-    }
-}
-
-void ant_bpwr_cadence_encode(uint8_t                     * p_page_buffer,
-                            ant_bpwr_common_data_t const * p_common_data)
-{
-    ant_bpwr_cadence_data_layout_t * p_outcoming_data = (ant_bpwr_cadence_data_layout_t *)p_page_buffer;
-    p_outcoming_data->instantaneous_cadence           = p_common_data->instantaneous_cadence;
-
-    cadence_data_log(p_common_data);
-}
-
-void ant_bpwr_cadence_decode(uint8_t const         * p_page_buffer,
-                            ant_bpwr_common_data_t * p_common_data)
-{
-    ant_bpwr_cadence_data_layout_t const * p_incoming_data = (ant_bpwr_cadence_data_layout_t *)p_page_buffer;
-    p_common_data->instantaneous_cadence                   = p_incoming_data->instantaneous_cadence;
-
-    cadence_data_log(p_common_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BPWR)

+ 0 - 99
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_common_data.h

@@ -1,99 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_COMMON_DATA_H__
-#define ANT_BPWR_COMMON_DATA_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bpwr_common_data_page Stride Based Speed and Distance Monitor profile common data
- * @{
- * @ingroup ant_sdk_profiles_bpwr_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for BPWR common data.
- *
- * @details This structure stores data that is not associated with a particular page.
- */
-typedef struct
-{
-    uint8_t  instantaneous_cadence; ///< Crank cadence (rpm, 0 - 254, 255-> invalid).
-} ant_bpwr_common_data_t;
-
-/**@brief Initialize common data.
- */
-#define DEFAULT_ANT_BPWR_COMMON_DATA()  \
-    (ant_bpwr_common_data_t)            \
-    {                                   \
-        .instantaneous_cadence  = 0,    \
-    }
-
-/**@brief Function for encoding speed.
- *
- * This function can be used for pages 16, 17, and 18.
- *
- * @param[in]  p_common_data    Pointer to the common data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bpwr_cadence_encode(uint8_t                     * p_page_buffer,
-                            ant_bpwr_common_data_t const * p_common_data);
-
-/**@brief Function for decoding speed.
- *
- * This function can be used for pages 16, 17, and 18.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_common_data    Pointer to the common data.
- */
-void ant_bpwr_cadence_decode(uint8_t const         * p_page_buffer,
-                            ant_bpwr_common_data_t * p_common_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_COMMON_DATA_H__
-/** @} */

+ 0 - 285
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_1.c

@@ -1,285 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BPWR)
-
-#include <string.h>
-#include "ant_bpwr_page_1.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_1"
-#if ANT_BPWR_PAGE_1_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BPWR_PAGE_1_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BPWR_PAGE_1_INFO_COLOR
-#else // ANT_BPWR_PAGE_1_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BPWR_PAGE_1_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief bicycle power page 1 data layout structure. */
-typedef struct
-{
-    uint8_t calibration_id; ///< Calibration request type
-    union
-    {
-        struct
-        {
-            uint8_t reserved[6]; ///< Unused, fill by 0xFF.
-        } general_calib_request;
-        struct
-        {
-            uint8_t auto_zero_status; ///< Status of automatic zero feature of power sensor.
-            uint8_t reserved[5];      ///< Unused, fill by 0xFF.
-        } auto_zero_config;
-        struct
-        {
-            uint8_t auto_zero_status; ///< Status of automatic zero feature of power sensor.
-            uint8_t reserved[3];      ///< Unused, fill by 0xFF.
-            uint8_t data[2];          ///< Calibration Data.
-        } general_calib_response;
-        struct
-        {
-            uint8_t enable      : 1;
-            uint8_t status      : 1;
-            uint8_t reserved0   : 6; ///< Unused, fill by 0x00.
-            uint8_t reserved1[5];    ///< Unused, fill by 0xFF.
-        } auto_zero_support;
-        struct
-        {
-            uint8_t manufac_spec[6]; ///< Manufacture Specyfic Data.
-        } custom_calib;
-    } data;
-} ant_bpwr_page1_data_layout_t;
-
-
-static void page1_data_log(ant_bpwr_page1_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Calibration id:                      %u\r\n", p_page_data->calibration_id);
-
-    switch (p_page_data->calibration_id)
-    {
-        case ANT_BPWR_CALIB_ID_MANUAL:
-            // No implementation needed
-            break;
-
-        case ANT_BPWR_CALIB_ID_MANUAL_SUCCESS:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_FAILED:
-            NRF_LOG_INFO("General calibration data:            %u\r\n",
-                         p_page_data->data.general_calib);
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_AUTO:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_AUTO_SUPPORT:
-
-            switch (p_page_data->auto_zero_status)
-            {
-                case ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED:
-                    NRF_LOG_INFO("Auto zero not supported\r\n\n");
-                    break;
-
-                case ANT_BPWR_AUTO_ZERO_OFF:
-                    NRF_LOG_INFO("Auto zero off\r\n\n");
-                    break;
-
-                case ANT_BPWR_AUTO_ZERO_ON:
-                    NRF_LOG_INFO("Auto zero on\r\n\n");
-                    break;
-            }
-            break;
-
-        case ANT_BPWR_CALIB_ID_CTF:
-            NRF_LOG_INFO("Not supported\r\n\n");
-            break;
-
-        case ANT_BPWR_CALIB_ID_CUSTOM_REQ:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS:
-            NRF_LOG_INFO("Manufacture specyfic:            ");
-            NRF_LOG_HEXDUMP_INFO((uint8_t*)p_page_data->data.custom_calib,
-                               sizeof (p_page_data->data.custom_calib));
-            break;
-
-        default: // shouldn't occur
-            NRF_LOG_INFO("Unsupported calibration ID\r\n\n");
-            break;
-    }
-}
-
-
-void ant_bpwr_page_1_encode(uint8_t                     * p_page_buffer,
-                            ant_bpwr_page1_data_t const * p_page_data)
-{
-    ant_bpwr_page1_data_layout_t * p_outcoming_data = (ant_bpwr_page1_data_layout_t *)p_page_buffer;
-
-    page1_data_log(p_page_data);
-
-    p_outcoming_data->calibration_id = p_page_data->calibration_id;
-
-    switch (p_page_data->calibration_id)
-    {
-        case ANT_BPWR_CALIB_ID_MANUAL:
-            memset(p_outcoming_data->data.general_calib_request.reserved, 0xFF,
-                   sizeof (p_outcoming_data->data.general_calib_request.reserved));
-            break;
-
-        case ANT_BPWR_CALIB_ID_AUTO:
-            memset(p_outcoming_data->data.auto_zero_config.reserved, 0xFF,
-                   sizeof (p_outcoming_data->data.auto_zero_config.reserved));
-            p_outcoming_data->data.auto_zero_config.auto_zero_status =
-                p_page_data->auto_zero_status;
-            break;
-
-        case ANT_BPWR_CALIB_ID_MANUAL_SUCCESS:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_FAILED:
-            memset(p_outcoming_data->data.general_calib_response.reserved, 0xFF,
-                   sizeof (p_outcoming_data->data.general_calib_response.reserved));
-            p_outcoming_data->data.general_calib_response.auto_zero_status =
-                p_page_data->auto_zero_status;
-            UNUSED_PARAMETER(uint16_encode(p_page_data->data.general_calib,
-                                           p_outcoming_data->data.general_calib_response.data));
-            break;
-
-        case ANT_BPWR_CALIB_ID_CTF:
-            NRF_LOG_INFO("Not supported\r\n");
-            break;
-
-        case ANT_BPWR_CALIB_ID_AUTO_SUPPORT:
-            memset(p_outcoming_data->data.auto_zero_support.reserved1, 0xFF,
-                   sizeof (p_outcoming_data->data.auto_zero_support.reserved1));
-            p_outcoming_data->data.auto_zero_support.reserved0 = 0x00;
-            p_outcoming_data->data.auto_zero_support.enable    =
-                (p_page_data->auto_zero_status == ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED) ? false : true;
-            p_outcoming_data->data.auto_zero_support.status =
-                (p_page_data->auto_zero_status == ANT_BPWR_AUTO_ZERO_ON) ? true : false;
-            break;
-
-        case ANT_BPWR_CALIB_ID_CUSTOM_REQ:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS:
-            memcpy(p_outcoming_data->data.custom_calib.manufac_spec,
-                   (void *)p_page_data->data.custom_calib,
-                   sizeof (p_page_data->data.custom_calib));
-            break;
-
-        default: // shouldn't occur
-            break;
-    }
-}
-
-
-void ant_bpwr_page_1_decode(uint8_t const         * p_page_buffer,
-                            ant_bpwr_page1_data_t * p_page_data)
-{
-    ant_bpwr_page1_data_layout_t const * p_incoming_data =
-        (ant_bpwr_page1_data_layout_t *)p_page_buffer;
-
-    p_page_data->calibration_id = (ant_bpwr_calib_id_t)p_incoming_data->calibration_id;
-
-    switch (p_incoming_data->calibration_id)
-    {
-        case ANT_BPWR_CALIB_ID_MANUAL:
-            // No implementation needed
-            break;
-
-        case ANT_BPWR_CALIB_ID_AUTO:
-            /* fall through */
-            p_page_data->auto_zero_status =
-                (ant_bpwr_auto_zero_status_t)p_incoming_data->data.auto_zero_config.auto_zero_status;
-            break;
-
-        case ANT_BPWR_CALIB_ID_MANUAL_SUCCESS:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_FAILED:
-            p_page_data->auto_zero_status =
-                (ant_bpwr_auto_zero_status_t)p_incoming_data->data.general_calib_response.
-                auto_zero_status;
-            p_page_data->data.general_calib = uint16_decode(
-                p_incoming_data->data.general_calib_response.data);
-            break;
-
-        case ANT_BPWR_CALIB_ID_CTF:
-            NRF_LOG_INFO("Not supported\r\n");
-            break;
-
-        case ANT_BPWR_CALIB_ID_AUTO_SUPPORT:
-
-            if (p_incoming_data->data.auto_zero_support.enable == false)
-            {
-                p_page_data->auto_zero_status = ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED;
-            }
-            else if (p_incoming_data->data.auto_zero_support.status)
-            {
-                p_page_data->auto_zero_status = ANT_BPWR_AUTO_ZERO_ON;
-            }
-            else
-            {
-                p_page_data->auto_zero_status = ANT_BPWR_AUTO_ZERO_OFF;
-            }
-            break;
-
-        case ANT_BPWR_CALIB_ID_CUSTOM_REQ:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE:
-        /* fall through */
-        case ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS:
-            memcpy((void *)p_page_data->data.custom_calib,
-                   p_incoming_data->data.custom_calib.manufac_spec,
-                   sizeof (p_page_data->data.custom_calib));
-            break;
-
-        default: // shouldn't occur
-            break;
-    }
-
-    page1_data_log(p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BPWR)

+ 0 - 136
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_1.h

@@ -1,136 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_PAGE_1_H__
-#define ANT_BPWR_PAGE_1_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bpwr_page1 Bicycle Power profile page 1
- * @{
- * @ingroup ant_sdk_profiles_bpwr_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief BPWR Calibration ID.
- */
-typedef enum
-{
-    ANT_BPWR_CALIB_ID_NONE                  = 0x00,
-    ANT_BPWR_CALIB_ID_MANUAL                = 0xAA, ///< Calibration Request: Manual Zero.
-    ANT_BPWR_CALIB_ID_AUTO                  = 0xAB, ///< Calibration Request: Auto Zero Configuration.
-    ANT_BPWR_CALIB_ID_MANUAL_SUCCESS        = 0xAC, ///< Calibration Response: Manual Zero Successful.
-    ANT_BPWR_CALIB_ID_FAILED                = 0xAF, ///< Calibration Response: Failed.
-    ANT_BPWR_CALIB_ID_CTF                   = 0x10, ///< Crank Torque Frequency (CTF) Power sensor Defined Message.
-    ANT_BPWR_CALIB_ID_AUTO_SUPPORT          = 0x12, ///< Auto Zero Support.
-    ANT_BPWR_CALIB_ID_CUSTOM_REQ            = 0xBA, ///< Custom Calibration Parameter Request.
-    ANT_BPWR_CALIB_ID_CUSTOM_REQ_SUCCESS    = 0xBB, ///< Custom Calibration Parameter Response.
-    ANT_BPWR_CALIB_ID_CUSTOM_UPDATE         = 0xBC, ///< Custom Calibration Parameter Update.
-    ANT_BPWR_CALIB_ID_CUSTOM_UPDATE_SUCCESS = 0xBD, ///< Custom Calibration Parameter Update Response.
-} ant_bpwr_calib_id_t;
-
-/**@brief BPWR Calibration Auto Zero Status.
- */
-typedef enum
-{
-    ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED = 0xFF, ///< Auto Zero Not Supported.
-    ANT_BPWR_AUTO_ZERO_OFF           = 0x00, ///< Auto Zero OFF.
-    ANT_BPWR_AUTO_ZERO_ON            = 0x01, ///< Auto Zero ON.
-} ant_bpwr_auto_zero_status_t;
-
-/**@brief Data structure for Bicycle Power data page 1.
- */
-typedef struct
-{
-    ant_bpwr_calib_id_t         calibration_id;   ///< Calibration request type.
-    ant_bpwr_auto_zero_status_t auto_zero_status; ///< Status of automatic zero feature of power sensor.
-    union
-    {
-        int16_t general_calib;
-        uint8_t custom_calib[6];
-    } data;
-} ant_bpwr_page1_data_t;
-
-/**@brief Initialize page 1.
- */
-#define DEFAULT_ANT_BPWR_PAGE1()                                \
-    (ant_bpwr_page1_data_t)                                     \
-    {                                                           \
-        .calibration_id     = ANT_BPWR_CALIB_ID_NONE,           \
-        .auto_zero_status   = ANT_BPWR_AUTO_ZERO_NOT_SUPPORTED, \
-        .data.general_calib = 0x00,                             \
-    }
-
-/**@brief Initialize page 1 with the general request.
- */
-#define ANT_BPWR_GENERAL_CALIB_REQUEST()            \
-    (ant_bpwr_page1_data_t)                         \
-    {                                               \
-        .calibration_id = ANT_BPWR_CALIB_ID_MANUAL, \
-    }
-
-/**@brief Function for encoding page 1.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bpwr_page_1_encode(uint8_t                     * p_page_buffer,
-                            ant_bpwr_page1_data_t const * p_page_data);
-
-/**@brief Function for decoding page 1.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bpwr_page_1_decode(uint8_t const         * p_page_buffer,
-                            ant_bpwr_page1_data_t * p_page_data);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_PAGE_1_H__
-/** @} */

+ 0 - 116
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_16.c

@@ -1,116 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BPWR)
-
-#include "ant_bpwr_page_16.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_16"
-#if ANT_BPWR_PAGE_16_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BPWR_PAGE_16_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BPWR_PAGE_16_INFO_COLOR
-#else // ANT_BPWR_PAGE_16_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BPWR_PAGE_16_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief bicycle power page 16 data layout structure. */
-typedef struct
-{
-    uint8_t update_event_count;
-    uint8_t pedal_power;
-    uint8_t reserved;
-    uint8_t accumulated_power[2];
-    uint8_t instantaneous_power[2];
-}ant_bpwr_page16_data_layout_t;
-
-
-static void page16_data_log(ant_bpwr_page16_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("event count:                        %u\r\n", p_page_data->update_event_count);
-
-    if (p_page_data->pedal_power.byte != 0xFF)
-    {
-        NRF_LOG_INFO("pedal power:                        %u %%\r\n",
-                   p_page_data->pedal_power.items.distribution);
-    }
-    else
-    {
-        NRF_LOG_INFO("pedal power:                        --\r\n");
-    }
-
-    NRF_LOG_INFO("accumulated power:                  %u W\r\n", p_page_data->accumulated_power);
-    NRF_LOG_INFO("instantaneous power:                %u W\r\n", p_page_data->instantaneous_power);
-}
-
-
-void ant_bpwr_page_16_encode(uint8_t                      * p_page_buffer,
-                             ant_bpwr_page16_data_t const * p_page_data)
-{
-    ant_bpwr_page16_data_layout_t * p_outcoming_data =
-        (ant_bpwr_page16_data_layout_t *)p_page_buffer;
-
-    p_outcoming_data->update_event_count    = p_page_data->update_event_count;
-    p_outcoming_data->pedal_power           = p_page_data->pedal_power.byte;
-
-    UNUSED_PARAMETER(uint16_encode(p_page_data->accumulated_power,
-                                   p_outcoming_data->accumulated_power));
-    UNUSED_PARAMETER(uint16_encode(p_page_data->instantaneous_power,
-                                   p_outcoming_data->instantaneous_power));
-
-    page16_data_log(p_page_data);
-}
-
-
-void ant_bpwr_page_16_decode(uint8_t const          * p_page_buffer,
-                             ant_bpwr_page16_data_t * p_page_data)
-{
-    ant_bpwr_page16_data_layout_t const * p_incoming_data =
-        (ant_bpwr_page16_data_layout_t *)p_page_buffer;
-
-    p_page_data->update_event_count    = p_incoming_data->update_event_count;
-    p_page_data->pedal_power.byte      = p_incoming_data->pedal_power;
-    p_page_data->accumulated_power     = uint16_decode(p_incoming_data->accumulated_power);
-    p_page_data->instantaneous_power   = uint16_decode(p_incoming_data->instantaneous_power);
-
-    page16_data_log(p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BPWR)

+ 0 - 111
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_16.h

@@ -1,111 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_PAGE_16_H__
-#define ANT_BPWR_PAGE_16_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bpwr_page16 Bicycle Power profile page 16
- * @{
- * @ingroup ant_sdk_profiles_bpwr_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for Bicycle Power data page 16.
- *
- * @note This structure implements only page 16 specific data.
- */
-typedef struct
-{
-    union
-    {
-        struct
-        {
-            uint8_t distribution : 7;     ///< Pedal power distribution (%).
-            uint8_t differentiation : 1;  ///< Pedal differentiation: 1 -> right, 0 -> unknown.
-        } items;
-        uint8_t byte;
-    } pedal_power;
-
-    uint8_t  update_event_count;    ///< Power event count.
-    uint16_t accumulated_power;     ///< Accumulated power (W).
-    uint16_t instantaneous_power;   ///< Instantaneous power (W).
-} ant_bpwr_page16_data_t;
-
-/**@brief Initialize page 16.
- */
-#define DEFAULT_ANT_BPWR_PAGE16()                               \
-    (ant_bpwr_page16_data_t)                                    \
-    {                                                           \
-        .update_event_count                 = 0,                \
-        .pedal_power.items.distribution     = 0,                \
-        .pedal_power.items.differentiation  = 0,                \
-        .accumulated_power                  = 0,                \
-        .instantaneous_power                = 0,                \
-    }
-
-/**@brief Function for encoding page 16.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bpwr_page_16_encode(uint8_t                      * p_page_buffer,
-                             ant_bpwr_page16_data_t const * p_page_data);
-
-/**@brief Function for decoding page 16.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bpwr_page_16_decode(uint8_t const          * p_page_buffer,
-                             ant_bpwr_page16_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_PAGE_16_H__
-/** @} */

+ 0 - 76
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_17.c

@@ -1,76 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BPWR)
-
-#include "ant_bpwr_page_17.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_17"
-#if ANT_BPWR_PAGE_17_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BPWR_PAGE_17_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BPWR_PAGE_17_INFO_COLOR
-#else // ANT_BPWR_PAGE_17_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BPWR_PAGE_17_LOG_ENABLED
-#include "nrf_log.h"
-
-static void page17_data_log(ant_bpwr_page17_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Wheel:\r\n");
-    ant_bpwr_page_torque_log((ant_bpwr_page_torque_data_t *) p_page_data);
-}
-
-
-void ant_bpwr_page_17_encode(uint8_t                      * p_page_buffer,
-                             ant_bpwr_page17_data_t const * p_page_data)
-{
-    ant_bpwr_page_torque_encode(p_page_buffer, (ant_bpwr_page_torque_data_t *)p_page_data);
-    page17_data_log(p_page_data);
-}
-
-
-void ant_bpwr_page_17_decode(uint8_t const          * p_page_buffer,
-                             ant_bpwr_page17_data_t * p_page_data)
-{
-    ant_bpwr_page_torque_decode(p_page_buffer, (ant_bpwr_page_torque_data_t *) p_page_data);
-    page17_data_log(p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BPWR)

+ 0 - 89
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_17.h

@@ -1,89 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_PAGE_17_H__
-#define ANT_BPWR_PAGE_17_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bpwr_page17 Bicycle Power profile page 17
- * @{
- * @ingroup ant_sdk_profiles_bpwr_pages
- */
-
-#include <stdint.h>
-#include "ant_bpwr_page_torque.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for Bicycle Power data page 17.
- *
- * @note This structure implements only page 17 specific data.
- */
-typedef ant_bpwr_page_torque_data_t ant_bpwr_page17_data_t;
-
-/**@brief Initialize page 17.
- */
-#define DEFAULT_ANT_BPWR_PAGE17() (ant_bpwr_page17_data_t) DEFAULT_ANT_BPWR_PAGE_TORQUE(0, 0, 0, 0)
-
-/**@brief Function for encoding page 17.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bpwr_page_17_encode(uint8_t                      * p_page_buffer,
-                             ant_bpwr_page17_data_t const * p_page_data);
-
-/**@brief Function for decoding page 17.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bpwr_page_17_decode(uint8_t const          * p_page_buffer,
-                             ant_bpwr_page17_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_PAGE_17_H__
-/** @} */

+ 0 - 76
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_18.c

@@ -1,76 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BPWR)
-
-#include "ant_bpwr_page_18.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_18"
-#if ANT_BPWR_PAGE_18_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BPWR_PAGE_18_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BPWR_PAGE_18_INFO_COLOR
-#else // ANT_BPWR_PAGE_18_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BPWR_PAGE_18_LOG_ENABLED
-#include "nrf_log.h"
-
-static void page18_data_log(ant_bpwr_page18_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Crank:\r\n");
-    ant_bpwr_page_torque_log((ant_bpwr_page_torque_data_t *) p_page_data);
-}
-
-
-void ant_bpwr_page_18_encode(uint8_t                      * p_page_buffer,
-                             ant_bpwr_page18_data_t const * p_page_data)
-{
-    ant_bpwr_page_torque_encode(p_page_buffer, (ant_bpwr_page_torque_data_t *)p_page_data);
-    page18_data_log(p_page_data);
-}
-
-
-void ant_bpwr_page_18_decode(uint8_t const          * p_page_buffer,
-                             ant_bpwr_page18_data_t * p_page_data)
-{
-    ant_bpwr_page_torque_decode(p_page_buffer, (ant_bpwr_page_torque_data_t *) p_page_data);
-    page18_data_log(p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BPWR)

+ 0 - 89
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_18.h

@@ -1,89 +0,0 @@
-/**
- * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_PAGE_18_H__
-#define ANT_BPWR_PAGE_18_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bpwr_page18 Bicycle Power profile page 18
- * @{
- * @ingroup ant_sdk_profiles_bpwr_pages
- */
-
-#include <stdint.h>
-#include "ant_bpwr_page_torque.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for Bicycle Power data page 18.
- *
- * @note This structure implements only page 18 specific data.
- */
-typedef ant_bpwr_page_torque_data_t ant_bpwr_page18_data_t;
-
-/**@brief Initialize page 18.
- */
-#define DEFAULT_ANT_BPWR_PAGE18() (ant_bpwr_page18_data_t) DEFAULT_ANT_BPWR_PAGE_TORQUE(0, 0, 0, 0)
-
-/**@brief Function for encoding page 18.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bpwr_page_18_encode(uint8_t                      * p_page_buffer,
-                             ant_bpwr_page18_data_t const * p_page_data);
-
-/**@brief Function for decoding page 18.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bpwr_page_18_decode(uint8_t const          * p_page_buffer,
-                             ant_bpwr_page18_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_PAGE_18_H__
-/** @} */

+ 0 - 112
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_torque.c

@@ -1,112 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BPWR)
-
-#include <stdio.h>
-#include "ant_bpwr_page_torque.h"
-#include "ant_bpwr_utils.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BPWR_PAGE_TORQUE"
-#if ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BPWR_PAGE_TORQUE_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BPWR_PAGE_TORQUE_INFO_COLOR
-#else // ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BPWR_PAGE_TORQUE_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief bicycle power page torque data layout structure. */
-typedef struct
-{
-    uint8_t update_event_count;
-    uint8_t tick;
-    uint8_t reserved;
-    uint8_t period[2];
-    uint8_t accumulated_torque[2];
-}ant_bpwr_page_torque_data_layout_t;
-
-STATIC_ASSERT(ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION == 1000); ///< Display format need to be updated
-STATIC_ASSERT(ANT_BPWR_ACC_TORQUE_DISP_PRECISION == 10);      ///< Display format need to be updated
-
-void ant_bpwr_page_torque_log(ant_bpwr_page_torque_data_t const * p_page_data)
-{
-    uint16_t period     = ANT_BPWR_TORQUE_PERIOD_RESCALE(p_page_data->period);
-    uint32_t acc_torque = ANT_BPWR_ACC_TORQUE_RESCALE(p_page_data->accumulated_torque);
-
-    NRF_LOG_INFO("event count:                    %u\r\n", p_page_data->update_event_count);
-    NRF_LOG_INFO("tick:                           %u\r\n", p_page_data->tick);
-    NRF_LOG_INFO("period:                         %u.%03us\r\n",
-                  (unsigned int)(period / ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION),
-                  (unsigned int)(period % ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION));
-    NRF_LOG_INFO("accumulated torque:             %u.%01uNm\r\n",
-                  (unsigned int)(acc_torque / ANT_BPWR_ACC_TORQUE_DISP_PRECISION),
-                  (unsigned int)(acc_torque % ANT_BPWR_ACC_TORQUE_DISP_PRECISION));
-}
-
-
-void ant_bpwr_page_torque_encode(uint8_t                           * p_page_buffer,
-                                 ant_bpwr_page_torque_data_t const * p_page_data)
-{
-    ant_bpwr_page_torque_data_layout_t * p_outcoming_data =
-        (ant_bpwr_page_torque_data_layout_t *)p_page_buffer;
-
-    p_outcoming_data->update_event_count    = p_page_data->update_event_count;
-    p_outcoming_data->tick                  = p_page_data->tick;
-
-    UNUSED_PARAMETER(uint16_encode(p_page_data->period, p_outcoming_data->period));
-    UNUSED_PARAMETER(uint16_encode(p_page_data->accumulated_torque,
-                                   p_outcoming_data->accumulated_torque));
-}
-
-
-void ant_bpwr_page_torque_decode(uint8_t const               * p_page_buffer,
-                                 ant_bpwr_page_torque_data_t * p_page_data)
-{
-    ant_bpwr_page_torque_data_layout_t const * p_incoming_data =
-        (ant_bpwr_page_torque_data_layout_t *)p_page_buffer;
-
-    p_page_data->update_event_count    = p_incoming_data->update_event_count;
-    p_page_data->tick                  = p_incoming_data->tick;
-    p_page_data->period                = uint16_decode(p_incoming_data->period);
-    p_page_data->accumulated_torque    = uint16_decode(p_incoming_data->accumulated_torque);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BPWR)

+ 0 - 106
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_page_torque.h

@@ -1,106 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_PAGE_TORQUE_COMMON_H__
-#define ANT_BPWR_PAGE_TORQUE_COMMON_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bicycle_p_page_torque Bicycle Power profile pages 17, 18 (commons)
- * @{
- * @ingroup ant_sdk_profiles_bpwr_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Common data structure for Bicycle Power data pages 17, 18.
- *
- * @note This structure implements specific data that is common for pages 17, 18.
- */
-typedef struct
-{
-    uint8_t  update_event_count;    ///< Power event count.
-    uint8_t  tick;                  ///< Wheel/crank revolutions counter.
-    uint16_t period;                ///< Accumulated wheel/crank period (1/2048 s).
-    uint16_t accumulated_torque;    ///< Accumulated wheel/torque (1/32 Nm).
-} ant_bpwr_page_torque_data_t;
-
-/**@brief Initialize page torque.
- */
-#define DEFAULT_ANT_BPWR_PAGE_TORQUE(up_evt_cnt, def_tick, def_period, acc_torque)  \
-    {                                                                               \
-        .update_event_count    = (up_evt_cnt),                                      \
-        .tick                  = (def_tick),                                        \
-        .period                = (def_period),                                      \
-        .accumulated_torque    = (acc_torque)                                       \
-    }
-
-/**@brief Function for encoding pages 17, 18.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bpwr_page_torque_encode(uint8_t                           * p_page_buffer,
-                                 ant_bpwr_page_torque_data_t const * p_page_data);
-
-/**@brief Function for decoding pages 17, 18.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bpwr_page_torque_decode(uint8_t const               * p_page_buffer,
-                                 ant_bpwr_page_torque_data_t * p_page_data);
-
-/**@brief Function for logging pages 17, 18.
- *
- * @param[in] p_page_data      Pointer to the page data.
- */
-void ant_bpwr_page_torque_log(ant_bpwr_page_torque_data_t const * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_PAGE_TORQUE_COMMON_H__
-/** @} */

+ 0 - 69
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/pages/ant_bpwr_pages.h

@@ -1,69 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_PAGES_H__
-#define ANT_BPWR_PAGES_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bpwr_pages Bicycle Power profile pages
- * @{
- * @ingroup ant_bpwr
- * @brief This module implements functions for the BPWR data pages.
- */
-
-#include "ant_bpwr_page_1.h"        // Calibration message main data page.
-#include "ant_bpwr_page_16.h"       // Standard power-only page.
-#include "ant_bpwr_page_17.h"       // Wheel Torque main data page.
-#include "ant_bpwr_page_18.h"       // Crank Torque main data page.
-#include "ant_bpwr_common_data.h"   // Instantaneous cadence data.
-#include "ant_common_page_80.h"     // Manufacturer's information data page.
-#include "ant_common_page_81.h"     // Product information data page.
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_PAGES_H__
-/** @} */

+ 0 - 201
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/simulator/ant_bpwr_simulator.c

@@ -1,201 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "ant_bpwr_simulator.h"
-#include "app_util.h"
-#include "nordic_common.h"
-
-#define POWER_MIN  0
-#define POWER_MAX  2000
-#define POWER_INCR 10
-
-#define CADENCE_MIN  0
-#define CADENCE_MAX  (UINT8_MAX - 1)
-#define CADENCE_INCR 1
-
-#define PEDAL_MIN  0
-#define PEDAL_MAX  100
-#define PEDAL_INCR 1
-
-#define TORQUE_PERIOD            774
-#define SIMULATOR_TIME_INCREMENT BPWR_MSG_PERIOD
-
-#define TORQUE_INCR 10
-
-
-void ant_bpwr_simulator_init(ant_bpwr_simulator_t           * p_simulator,
-                             ant_bpwr_simulator_cfg_t const * p_config,
-                             bool                             auto_change)
-{
-    p_simulator->p_profile      = p_config->p_profile;
-    p_simulator->_cb.auto_change = auto_change;
-    p_simulator->_cb.tick_incr   = 0;
-
-    p_simulator->_cb.power_sensorsim_cfg.min          = POWER_MIN;
-    p_simulator->_cb.power_sensorsim_cfg.max          = POWER_MAX;
-    p_simulator->_cb.power_sensorsim_cfg.incr         = POWER_INCR;
-    p_simulator->_cb.power_sensorsim_cfg.start_at_max = false;
-
-    p_simulator->_cb.cadence_sensorsim_cfg.min          = CADENCE_MIN;
-    p_simulator->_cb.cadence_sensorsim_cfg.max          = CADENCE_MAX;
-    p_simulator->_cb.cadence_sensorsim_cfg.incr         = CADENCE_INCR;
-    p_simulator->_cb.cadence_sensorsim_cfg.start_at_max = false;
-
-    p_simulator->_cb.pedal_sensorsim_cfg.min          = PEDAL_MIN;
-    p_simulator->_cb.pedal_sensorsim_cfg.max          = PEDAL_MAX;
-    p_simulator->_cb.pedal_sensorsim_cfg.incr         = PEDAL_INCR;
-    p_simulator->_cb.pedal_sensorsim_cfg.start_at_max = false;
-
-    p_simulator->p_profile->BPWR_PROFILE_pedal_power.differentiation = 0x01; // right
-
-    sensorsim_init(&(p_simulator->_cb.power_sensorsim_state),
-                   &(p_simulator->_cb.power_sensorsim_cfg));
-    sensorsim_init(&(p_simulator->_cb.cadence_sensorsim_state),
-                   &(p_simulator->_cb.cadence_sensorsim_cfg));
-    sensorsim_init(&(p_simulator->_cb.pedal_sensorsim_state),
-                   &(p_simulator->_cb.pedal_sensorsim_cfg));
-}
-
-
-void ant_bpwr_simulator_one_iteration(ant_bpwr_simulator_t * p_simulator, ant_bpwr_evt_t event)
-{
-    switch (event)
-    {
-        case ANT_BPWR_PAGE_16_UPDATED:
-
-            if (p_simulator->_cb.auto_change)
-            {
-                UNUSED_PARAMETER(sensorsim_measure(&(p_simulator->_cb.power_sensorsim_state),
-                                                   &(p_simulator->_cb.power_sensorsim_cfg)));
-                UNUSED_PARAMETER(sensorsim_measure(&(p_simulator->_cb.cadence_sensorsim_state),
-                                                   &(p_simulator->_cb.cadence_sensorsim_cfg)));
-                UNUSED_PARAMETER(sensorsim_measure(&(p_simulator->_cb.pedal_sensorsim_state),
-                                                   &(p_simulator->_cb.pedal_sensorsim_cfg)));
-            }
-
-            p_simulator->p_profile->BPWR_PROFILE_instantaneous_power =
-                p_simulator->_cb.power_sensorsim_state.current_val;
-            p_simulator->p_profile->BPWR_PROFILE_accumulated_power +=
-                p_simulator->_cb.power_sensorsim_state.current_val;
-
-            if (p_simulator->p_profile->BPWR_PROFILE_accumulated_power == UINT16_MAX)
-            {
-                p_simulator->p_profile->BPWR_PROFILE_accumulated_power = 0;
-            }
-            p_simulator->p_profile->BPWR_PROFILE_instantaneous_cadence =
-                 p_simulator->_cb.cadence_sensorsim_state.current_val;
-            p_simulator->p_profile->BPWR_PROFILE_pedal_power.distribution =
-                p_simulator->_cb.pedal_sensorsim_state.current_val;
-            p_simulator->p_profile->BPWR_PROFILE_power_update_event_count++;
-            break;
-
-        case ANT_BPWR_PAGE_17_UPDATED:
-
-            if (p_simulator->_cb.auto_change)
-            {
-                UNUSED_PARAMETER(sensorsim_measure(&(p_simulator->_cb.cadence_sensorsim_state),
-                                                   &(p_simulator->_cb.cadence_sensorsim_cfg)));
-            }
-            p_simulator->p_profile->BPWR_PROFILE_instantaneous_cadence =
-                 p_simulator->_cb.cadence_sensorsim_state.current_val;
-            p_simulator->p_profile->BPWR_PROFILE_wheel_period += TORQUE_PERIOD;
-            p_simulator->_cb.tick_incr                        +=
-                SIMULATOR_TIME_INCREMENT;
-            p_simulator->p_profile->BPWR_PROFILE_wheel_tick +=
-                p_simulator->_cb.tick_incr / (TORQUE_PERIOD * 16);
-            p_simulator->_cb.tick_incr =
-                p_simulator->_cb.tick_incr % (TORQUE_PERIOD * 16);
-            p_simulator->p_profile->BPWR_PROFILE_wheel_accumulated_torque += TORQUE_INCR;
-            p_simulator->p_profile->BPWR_PROFILE_wheel_update_event_count++;
-            break;
-
-        case ANT_BPWR_PAGE_18_UPDATED:
-
-            if (p_simulator->_cb.auto_change)
-            {
-                UNUSED_PARAMETER(sensorsim_measure(&(p_simulator->_cb.cadence_sensorsim_state),
-                                                   &(p_simulator->_cb.cadence_sensorsim_cfg)));
-            }
-            p_simulator->p_profile->BPWR_PROFILE_instantaneous_cadence =
-                 p_simulator->_cb.cadence_sensorsim_state.current_val;
-            p_simulator->p_profile->BPWR_PROFILE_crank_period = TORQUE_PERIOD;
-            p_simulator->_cb.tick_incr                        +=
-                SIMULATOR_TIME_INCREMENT;
-            p_simulator->p_profile->BPWR_PROFILE_crank_tick +=
-                p_simulator->_cb.tick_incr / (TORQUE_PERIOD * 16);
-            p_simulator->_cb.tick_incr =
-                p_simulator->_cb.tick_incr % (TORQUE_PERIOD * 16);
-            p_simulator->p_profile->BPWR_PROFILE_crank_accumulated_torque += TORQUE_INCR;
-            p_simulator->p_profile->BPWR_PROFILE_crank_update_event_count++;
-            break;
-
-        default:
-            break;
-    }
-}
-
-
-void ant_bpwr_simulator_increment(ant_bpwr_simulator_t * p_simulator)
-{
-    if (!p_simulator->_cb.auto_change)
-    {
-        sensorsim_increment(&(p_simulator->_cb.power_sensorsim_state),
-                            &(p_simulator->_cb.power_sensorsim_cfg));
-        sensorsim_increment(&(p_simulator->_cb.cadence_sensorsim_state),
-                            &(p_simulator->_cb.cadence_sensorsim_cfg));
-        sensorsim_increment(&(p_simulator->_cb.pedal_sensorsim_state),
-                            &(p_simulator->_cb.pedal_sensorsim_cfg));
-    }
-}
-
-
-void ant_bpwr_simulator_decrement(ant_bpwr_simulator_t * p_simulator)
-{
-    if (!p_simulator->_cb.auto_change)
-    {
-        sensorsim_decrement(&(p_simulator->_cb.power_sensorsim_state),
-                            &(p_simulator->_cb.power_sensorsim_cfg));
-        sensorsim_decrement(&(p_simulator->_cb.cadence_sensorsim_state),
-                            &(p_simulator->_cb.cadence_sensorsim_cfg));
-        sensorsim_decrement(&(p_simulator->_cb.pedal_sensorsim_state),
-                            &(p_simulator->_cb.pedal_sensorsim_cfg));
-    }
-}
-
-

+ 0 - 123
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/simulator/ant_bpwr_simulator.h

@@ -1,123 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_SIMULATOR_H__
-#define ANT_BPWR_SIMULATOR_H__
-
-/** @file
- *
- * @defgroup ant_sdk_simulators ANT simulators
- * @ingroup ant_sdk_utils
- * @brief Modules that simulate sensors.
- *
- * @defgroup ant_sdk_bpwr_simulator ANT BPWR simulator
- * @{
- * @ingroup ant_sdk_simulators
- * @brief ANT BPWR simulator module.
- *
- * @details This module simulates power for the ANT BPWR profile. The module calculates
- * abstract values, which are handled by the BPWR pages data model to ensure that they are
- * compatible. It provides a handler for changing the power value manually and functionality
- * for changing the power automatically.
- *
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "bsp.h"
-#include "ant_bpwr.h"
-#include "sensorsim.h"
-#include "ant_bpwr_simulator_local.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief BPWR simulator configuration structure. */
-typedef struct
-{
-    ant_bpwr_profile_t * p_profile;   ///< Related profile.
-    ant_bpwr_torque_t    sensor_type; ///< Type of related sensor.
-} ant_bpwr_simulator_cfg_t;
-
-/**@brief BPWR simulator structure. */
-typedef struct
-{
-    ant_bpwr_profile_t      * p_profile;    ///< Related profile.
-    ant_bpwr_simulator_cb_t   _cb;          ///< Internal control block.
-} ant_bpwr_simulator_t;
-
-
-/**@brief Function for initializing the ANT BPWR simulator instance.
- *
- * @param[in]  p_simulator      Pointer to the simulator instance.
- * @param[in]  p_config         Pointer to the simulator configuration structure.
- * @param[in]  auto_change      Enable or disable automatic changes of the power.
- */
-void ant_bpwr_simulator_init(ant_bpwr_simulator_t           * p_simulator,
-                             ant_bpwr_simulator_cfg_t const * p_config,
-                             bool                             auto_change);
-
-/**@brief Function for simulating a device event.
- *
- * @details Based on this event, the transmitter data is simulated.
- *
- * This function should be called in the BPWR TX event handler.
- */
-void ant_bpwr_simulator_one_iteration(ant_bpwr_simulator_t * p_simulator, ant_bpwr_evt_t event);
-
-/**@brief Function for incrementing the power value.
- *
- * @param[in]  p_simulator      Pointer to the simulator instance.
- */
-void ant_bpwr_simulator_increment(ant_bpwr_simulator_t * p_simulator);
-
-/**@brief Function for decrementing the power value.
- *
- * @param[in]  p_simulator      Pointer to the simulator instance.
- */
-void ant_bpwr_simulator_decrement(ant_bpwr_simulator_t * p_simulator);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_SIMULATOR_H__
-/** @} */

+ 0 - 74
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/simulator/ant_bpwr_simulator_local.h

@@ -1,74 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_SIMULATOR_LOCAL_H__
-#define ANT_BPWR_SIMULATOR_LOCAL_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "bsp.h"
-#include "ant_bpwr.h"
-#include "sensorsim.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @ingroup ant_sdk_bpwr_simulator
- * @brief BPWR simulator control block structure. */
-typedef struct
-{
-    bool              auto_change;             ///< Power will change automatically (if auto_change is set) or manually.
-    uint32_t          tick_incr;               ///< Fractional part of tick increment.
-    sensorsim_state_t power_sensorsim_state;   ///< Power state of the simulated sensor.
-    sensorsim_cfg_t   power_sensorsim_cfg;     ///< Power configuration of the simulated sensor.
-    sensorsim_state_t cadence_sensorsim_state; ///< Cadence stated of the simulated sensor.
-    sensorsim_cfg_t   cadence_sensorsim_cfg;   ///< Cadence configuration of the simulated sensor.
-    sensorsim_state_t pedal_sensorsim_state;   ///< Pedal state of the simulated sensor.
-    sensorsim_cfg_t   pedal_sensorsim_cfg;     ///< Pedal configuration of the simulated sensor.
-}ant_bpwr_simulator_cb_t;
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_SIMULATOR_LOCAL_H__

+ 0 - 86
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bpwr/utils/ant_bpwr_utils.h

@@ -1,86 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BPWR_UTILS_H__
-#define ANT_BPWR_UTILS_H__
-
-#include "app_util.h"
-#include "nrf_assert.h"
-#include "nrf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bpwr_utils Bicycle Power profile utilities
- * @{
- * @ingroup ant_bpwr
- * @brief This module implements utilities for the Bicycle Power profile.
- *
- */
-
-/*@brief A reversal of torque period unit.
- *
- * @details According to the ANT BPWR specification, the torque period unit is 1/2048 of a second.
- */
-#define ANT_BPWR_TORQUE_PERIOD_UNIT_REVERSAL                2048
-#define ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION               1000
-#define ANT_BPWR_TORQUE_PERIOD_RESCALE(VALUE)               value_rescale((VALUE), ANT_BPWR_TORQUE_PERIOD_UNIT_REVERSAL,  \
-                                                                            ANT_BPWR_TORQUE_PERIOD_DISP_PRECISION)
-
-/*@brief A reversal of accumulated torque unit.
- *
- * @details According to the ANT BPWR specification, the accumulated torque unit is 1/32 of a Nm.
- */
-#define ANT_BPWR_ACC_TORQUE_UNIT_REVERSAL                   32
-#define ANT_BPWR_ACC_TORQUE_DISP_PRECISION                  10
-#define ANT_BPWR_ACC_TORQUE_RESCALE(VALUE)                  value_rescale((VALUE), ANT_BPWR_ACC_TORQUE_UNIT_REVERSAL,  \
-                                                                            ANT_BPWR_ACC_TORQUE_DISP_PRECISION)
-
-/** @} */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BPWR_UTILS_H__
-

+ 0 - 420
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/ant_bsc.c

@@ -1,420 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BSC)
-
-#include "nrf_assert.h"
-#include "nrf_error.h"
-#include "app_error.h"
-#include "ant_interface.h"
-#include "ant_bsc.h"
-#include "ant_bsc_utils.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BSC"
-#if ANT_BSC_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BSC_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BSC_INFO_COLOR
-#else // ANT_BSC_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BSC_LOG_ENABLED
-#include "nrf_log.h"
-
-#define MAIN_DATA_INTERVAL          4       /**< The number of background data pages sent between main data pages.*/
-#define BACKGROUND_DATA_INTERVAL    64      /**< The number of main data pages sent between background data page.
-                                                 Background data page is sent every 65th message. */
-#define TX_TOGGLE_DIVISOR           4       /**< The number of messages between changing state of toggle bit. */
-
-/**@brief BSC message data layout structure. */
-typedef struct
-{
-    ant_bsc_page_t  page_number         : 7;
-    uint8_t         toggle_bit          : 1;
-    uint8_t         page_payload[7];
-}ant_bsc_single_message_layout_t;
-
-typedef struct
-{
-    uint8_t         page_payload[8];
-}ant_bsc_combined_message_layout_t;
-
-typedef union
-{
-    ant_bsc_single_message_layout_t     speed_or_cadence;
-    ant_bsc_combined_message_layout_t   combined;
-}ant_bsc_message_layout_t;
-
-
-/**@brief Function for initializing the ANT BSC profile instance.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- * @param[in]  p_channel_config Pointer to the ANT channel configuration structure.
- *
- * @retval     NRF_SUCCESS      If initialization was successful. Otherwise, an error code is returned.
- */
-static ret_code_t ant_bsc_init(ant_bsc_profile_t          * p_profile,
-                               ant_channel_config_t const * p_channel_config)
-{
-    p_profile->channel_number = p_channel_config->channel_number;
-
-    p_profile->page_0       = DEFAULT_ANT_BSC_PAGE0();
-    p_profile->page_1       = DEFAULT_ANT_BSC_PAGE1();
-    p_profile->page_2       = DEFAULT_ANT_BSC_PAGE2();
-    p_profile->page_3       = DEFAULT_ANT_BSC_PAGE3();
-    p_profile->page_4       = DEFAULT_ANT_BSC_PAGE4();
-    p_profile->page_5       = DEFAULT_ANT_BSC_PAGE5();
-    p_profile->page_comb_0  = DEFAULT_ANT_BSC_COMBINED_PAGE0();
-
-    NRF_LOG_INFO("ANT BSC channel %u init\r\n", p_profile->channel_number);
-    return ant_channel_init(p_channel_config);
-}
-
-ret_code_t ant_bsc_disp_init(ant_bsc_profile_t           * p_profile,
-                             ant_channel_config_t const  * p_channel_config,
-                             ant_bsc_disp_config_t const * p_disp_config)
-{
-    ASSERT(p_profile != NULL);
-    ASSERT(p_channel_config != NULL);
-    ASSERT(p_disp_config->evt_handler != NULL);
-
-    p_profile->evt_handler   = p_disp_config->evt_handler;
-    p_profile->_cb.p_disp_cb = p_disp_config->p_cb;
-
-    p_profile->_cb.p_disp_cb->device_type = p_channel_config->device_type;
-
-    return ant_bsc_init(p_profile, p_channel_config);
-}
-
-ret_code_t ant_bsc_sens_init(ant_bsc_profile_t           * p_profile,
-                             ant_channel_config_t const  * p_channel_config,
-                             ant_bsc_sens_config_t const * p_sens_config)
-{
-    ASSERT(p_profile != NULL);
-    ASSERT(p_channel_config != NULL);
-    ASSERT(p_sens_config != NULL);
-    ASSERT(p_sens_config->p_cb != NULL);
-    ASSERT(p_sens_config->evt_handler != NULL);
-
-    ASSERT((p_sens_config->main_page_number == ANT_BSC_PAGE_0)
-        || (p_sens_config->main_page_number == ANT_BSC_PAGE_5)
-        || (p_sens_config->main_page_number == ANT_BSC_COMB_PAGE_0));
-
-    p_profile->evt_handler   = p_sens_config->evt_handler;
-    p_profile->_cb.p_sens_cb = p_sens_config->p_cb;
-
-    p_profile->_cb.p_sens_cb->page_1_present    = p_sens_config->page_1_present;
-    p_profile->_cb.p_sens_cb->page_4_present    = p_sens_config->page_4_present;
-    p_profile->_cb.p_sens_cb->main_page_number  = p_sens_config->main_page_number;
-    p_profile->_cb.p_sens_cb->bkgd_page_number  =
-                            p_sens_config->page_1_present ? ANT_BSC_PAGE_1 : ANT_BSC_PAGE_2;
-    p_profile->_cb.p_sens_cb->message_counter   = 0;
-    p_profile->_cb.p_sens_cb->toggle_bit        = true;
-    p_profile->_cb.p_sens_cb->device_type       = p_channel_config->device_type;  /* Device type is set up in channel config */
-
-    return ant_bsc_init(p_profile, p_channel_config);
-}
-
-/**@brief Function for setting the next background page number.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- *
- */
-__STATIC_INLINE void next_bkgd_page_number_set(ant_bsc_profile_t * p_profile)
-{
-    /* Determine the last background page*/
-    ant_bsc_page_t last_bkgd_page =
-                p_profile->_cb.p_sens_cb->page_4_present ? ANT_BSC_PAGE_4 : ANT_BSC_PAGE_3;
-
-    /* Switch the background page according to user settings */
-    ++(p_profile->_cb.p_sens_cb->bkgd_page_number);
-    if (p_profile->_cb.p_sens_cb->bkgd_page_number > last_bkgd_page)
-    {
-        p_profile->_cb.p_sens_cb->bkgd_page_number =
-                    p_profile->_cb.p_sens_cb->page_1_present ? ANT_BSC_PAGE_1 : ANT_BSC_PAGE_2;
-    }
-}
-
-/**@brief Function for getting next page number to send.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- *
- * @return     Next page number.
- */
-static ant_bsc_page_t next_page_number_get(ant_bsc_profile_t * p_profile)
-{
-    ant_bsc_page_t page_number;
-
-    /* This is a single speed or cadence sensor - switch data page */
-    if (p_profile->_cb.p_sens_cb->message_counter < (BACKGROUND_DATA_INTERVAL))
-    {
-        /* Return main page */
-        page_number  = p_profile->_cb.p_sens_cb->main_page_number;
-    }
-    else
-    {
-        /* Return background page */
-        page_number  = p_profile->_cb.p_sens_cb->bkgd_page_number;
-    }
-
-    /* Set page toggle bit */
-    if ((p_profile->_cb.p_sens_cb->message_counter % TX_TOGGLE_DIVISOR) == 0)
-    {
-        p_profile->_cb.p_sens_cb->toggle_bit ^= 1;
-    }
-
-    /* Update message counter, wrap when counter equals 64 + 4 */
-    ++(p_profile->_cb.p_sens_cb->message_counter);
-    if (p_profile->_cb.p_sens_cb->message_counter == (BACKGROUND_DATA_INTERVAL + MAIN_DATA_INTERVAL))
-    {
-        p_profile->_cb.p_sens_cb->message_counter = 0;
-        /* Set new background data page number */
-        next_bkgd_page_number_set(p_profile);
-    }
-
-    return page_number;
-}
-
-/**@brief Function for encoding BSC message.
- *
- * @param[in]  p_profile         Pointer to the profile instance.
- * @param[out] p_message_payload Pointer to the message payload structure.
- *
- * @note Assume to be called each time when Tx window will occur.
- */
-static void sens_message_encode(ant_bsc_profile_t * p_profile, uint8_t * p_message_payload)
-{
-    ant_bsc_message_layout_t * p_bsc_message_payload = (ant_bsc_message_layout_t *)p_message_payload;
-    ant_bsc_evt_t              bsc_sens_event;
-
-    if (p_profile->_cb.p_sens_cb->device_type == BSC_COMBINED_DEVICE_TYPE)
-    {
-        NRF_LOG_INFO("BSC TX Page: \"Combined Speed & Cadence Page\"\r\n");
-        ant_bsc_combined_page_0_encode(p_bsc_message_payload->combined.page_payload,
-                                       &(p_profile->page_comb_0));
-        bsc_sens_event = (ant_bsc_evt_t) ANT_BSC_COMB_PAGE_0_UPDATED;
-    }
-    else
-    {
-        p_bsc_message_payload->speed_or_cadence.page_number = next_page_number_get(p_profile);
-        p_bsc_message_payload->speed_or_cadence.toggle_bit  = p_profile->_cb.p_sens_cb->toggle_bit;
-        NRF_LOG_INFO("BSC TX Page number: %u\r\n",
-                p_bsc_message_payload->speed_or_cadence.page_number);
-
-        ant_bsc_page_0_encode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                              &(p_profile->page_0));
-        bsc_sens_event = (ant_bsc_evt_t) p_bsc_message_payload->speed_or_cadence.page_number;
-
-        switch (p_bsc_message_payload->speed_or_cadence.page_number)
-        {
-            case ANT_BSC_PAGE_0:
-                // No implementation needed
-                break;
-            case  ANT_BSC_PAGE_1:
-                ant_bsc_page_1_encode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_1));
-                break;
-            case ANT_BSC_PAGE_2:
-                ant_bsc_page_2_encode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_2));
-                break;
-            case ANT_BSC_PAGE_3:
-                ant_bsc_page_3_encode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_3));
-                break;
-            case ANT_BSC_PAGE_4:
-                ant_bsc_page_4_encode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_4));
-                break;
-            case ANT_BSC_PAGE_5:
-                ant_bsc_page_5_encode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_5));
-                break;
-            default:
-                // No implementation needed
-                break;
-        }
-    }
-
-    p_profile->evt_handler(p_profile, bsc_sens_event);
-}
-
-/**@brief Function for setting payload for ANT message and sending it.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- */
-static void ant_message_send(ant_bsc_profile_t * p_profile)
-{
-    uint8_t p_message_payload[ANT_STANDARD_DATA_PAYLOAD_SIZE];
-    uint32_t err_code;
-
-    sens_message_encode(p_profile, p_message_payload);
-    err_code = sd_ant_broadcast_message_tx(p_profile->channel_number,
-                                           sizeof(p_message_payload),
-                                           p_message_payload);
-    APP_ERROR_CHECK(err_code);
-}
-
-void ant_bsc_sens_evt_handler(ant_bsc_profile_t * p_profile,
-                              ant_evt_t * p_ant_event)
-{
-    if (p_ant_event->channel == p_profile->channel_number)
-    {
-        switch (p_ant_event->event)
-        {
-            case EVENT_TX:
-                ant_message_send(p_profile);
-                break;
-
-            default:
-                break;
-        }
-    }
-}
-
-ret_code_t ant_bsc_disp_open(ant_bsc_profile_t * p_profile)
-{
-    ASSERT(p_profile != NULL);
-
-    NRF_LOG_INFO("ANT BSC channel %u open\r\n", p_profile->channel_number);
-    return sd_ant_channel_open(p_profile->channel_number);
-}
-
-ret_code_t ant_bsc_sens_open(ant_bsc_profile_t * p_profile)
-{
-    ASSERT(p_profile != NULL);
-
-    // Fill tx buffer for the first frame
-    ant_message_send(p_profile);
-
-    NRF_LOG_INFO("ANT BSC channel %u open\r\n", p_profile->channel_number);
-    return sd_ant_channel_open(p_profile->channel_number);
-}
-
-/**@brief Function for decoding BSC message.
- *
- * @param[in,out] p_profile         Pointer to the profile instance.
- * @param[in]     p_message_payload Pointer to the message payload structure.
- *
- * @note Assume to be call each time when Rx window will occur.
- */
-static void disp_message_decode(ant_bsc_profile_t * p_profile, uint8_t * p_message_payload)
-{
-    const ant_bsc_message_layout_t * p_bsc_message_payload =
-                                    (ant_bsc_message_layout_t *)p_message_payload;
-    ant_bsc_evt_t                    bsc_disp_event;
-
-    if (p_profile->_cb.p_disp_cb->device_type == BSC_COMBINED_DEVICE_TYPE)
-    {
-        NRF_LOG_INFO("BSC RX Page Number: \"Combined Speed & Cadence Page\"\r\n");
-        ant_bsc_combined_page_0_decode(p_bsc_message_payload->combined.page_payload,
-                                       &(p_profile->page_comb_0));
-        bsc_disp_event = (ant_bsc_evt_t) ANT_BSC_COMB_PAGE_0_UPDATED;
-    }
-    else
-    {
-        NRF_LOG_INFO("BSC RX Page Number: %u\r\n",
-                p_bsc_message_payload->speed_or_cadence.page_number);
-        ant_bsc_page_0_decode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                              &(p_profile->page_0)); // Page 0 is present in each message
-        bsc_disp_event = (ant_bsc_evt_t) p_bsc_message_payload->speed_or_cadence.page_number;
-
-        switch (p_bsc_message_payload->speed_or_cadence.page_number)
-        {
-            case ANT_BSC_PAGE_0:
-                // No implementation needed
-                break;
-
-            case ANT_BSC_PAGE_1:
-                ant_bsc_page_1_decode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_1));
-                break;
-
-            case ANT_BSC_PAGE_2:
-                ant_bsc_page_2_decode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_2));
-                break;
-
-            case ANT_BSC_PAGE_3:
-                ant_bsc_page_3_decode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_3));
-                break;
-
-            case ANT_BSC_PAGE_4:
-                ant_bsc_page_4_decode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_4));
-                break;
-
-            case ANT_BSC_PAGE_5:
-                ant_bsc_page_5_decode(p_bsc_message_payload->speed_or_cadence.page_payload,
-                                      &(p_profile->page_5));
-                break;
-
-            default:
-                // No implementation needed
-                break;
-        }
-    }
-
-    p_profile->evt_handler(p_profile, bsc_disp_event);
-}
-
-void ant_bsc_disp_evt_handler(ant_bsc_profile_t * p_profile,
-                              ant_evt_t * p_ant_event)
-{
-    if (p_ant_event->channel == p_profile->channel_number)
-    {
-        ANT_MESSAGE * p_message = (ANT_MESSAGE *)p_ant_event->msg.evt_buffer;
-        switch (p_ant_event->event)
-        {
-            case EVENT_RX:
-
-                if (p_message->ANT_MESSAGE_ucMesgID == MESG_BROADCAST_DATA_ID
-                    || p_message->ANT_MESSAGE_ucMesgID == MESG_ACKNOWLEDGED_DATA_ID
-                    || p_message->ANT_MESSAGE_ucMesgID == MESG_BURST_DATA_ID)
-                {
-                    disp_message_decode(p_profile, p_message->ANT_MESSAGE_aucPayload);
-                }
-                break;
-            default:
-                break;
-        }
-    }
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BSC)

+ 0 - 361
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/ant_bsc.h

@@ -1,361 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-/** @file
- *
- * @defgroup ant_bsc Bicycle Speed and Cadence profile
- * @{
- * @ingroup ant_sdk_profiles
- * @brief This module implements the Bicycle Speed and Cadence profile.
- *
- */
-
-#ifndef ANT_BSC_H__
-#define ANT_BSC_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "sdk_errors.h"
-#include "ant_parameters.h"
-#include "ant_stack_handler_types.h"
-#include "ant_channel_config.h"
-#include "ant_bsc_pages.h"
-
-#define BSC_ANTPLUS_RF_FREQ      0x39u                      ///< Frequency, decimal 57 (2457 MHz).
-
-#define BSC_SPEED_DEVICE_TYPE    0x7B                       ///< Device type reserved for ANT+ bike speed sensor.
-#define BSC_CADENCE_DEVICE_TYPE  0x7A                       ///< Device type reserved for ANT+ bike cadence sensor.
-#define BSC_COMBINED_DEVICE_TYPE 0x79                       ///< Device type reserved for ANT+ bike combined speed and cadence sensor.
-
-#define BSC_MSG_PERIOD_4Hz       1u                         ///< Message period, 4 Hz (in basic period counts, where basic period time = 0.25 s).
-#define BSC_MSG_PERIOD_2Hz       2u                         ///< Message period, 2 Hz (in basic period counts).
-#define BSC_MSG_PERIOD_1Hz       4u                         ///< Message period, 1 Hz (in basic period counts).
-#define BSC_MSG_PERIOD_SPEED     0x1FB6u                    ///< Message period in ticks, decimal 8118 (4.04 Hz).
-#define BSC_MSG_PERIOD_CADENCE   0x1FA6u                    ///< Message period in ticks, decimal 8102 (4.04 Hz).
-#define BSC_MSG_PERIOD_COMBINED  0x1F96u                    ///< Message period in ticks, decimal 8086 (4.05 Hz).
-
-
-#define BSC_EXT_ASSIGN           0x00                       ///< ANT ext assign (see Ext. Assign Channel Parameters in ant_parameters.h: @ref ant_parameters).
-#define BSC_DISP_CHANNEL_TYPE    CHANNEL_TYPE_SLAVE_RX_ONLY ///< Display BSC channel type.
-#define BSC_SENS_CHANNEL_TYPE    CHANNEL_TYPE_MASTER        ///< Sensor BSC channel type.
-
-
-/**@brief Select the basic ANT channel period (in ticks) for the BSC profile depending on the device type.
- *
- * @param[in]  DEVICE_TYPE          Type of device. Supported types: @ref BSC_SPEED_DEVICE_TYPE, @ref BSC_CADENCE_DEVICE_TYPE,
- *                                  @ref BSC_COMBINED_DEVICE_TYPE.
- */
-#define BSC_DEVICE_TICKS(DEVICE_TYPE)                                                   \
-        ((DEVICE_TYPE) == (BSC_SPEED_DEVICE_TYPE) ? (BSC_MSG_PERIOD_SPEED) :            \
-        ((DEVICE_TYPE) == (BSC_CADENCE_DEVICE_TYPE) ? (BSC_MSG_PERIOD_CADENCE) :        \
-        ((DEVICE_TYPE) == (BSC_COMBINED_DEVICE_TYPE) ? (BSC_MSG_PERIOD_COMBINED) : 0u)))
-
-/**@brief Calculate the channel period (in ticks) depending on the device type and the chosen message frequency.
- *
- * @param[in]  DEVICE_TYPE          Type of device. Supported types: @ref BSC_SPEED_DEVICE_TYPE, @ref BSC_CADENCE_DEVICE_TYPE,
- *                                  @ref BSC_COMBINED_DEVICE_TYPE.
- * @param[in]  BSC_MSG_PERIOD       Channel data period. The BSC profile supports only the following periods:
- *                                  @ref BSC_MSG_PERIOD_4Hz, @ref BSC_MSG_PERIOD_2Hz, @ref BSC_MSG_PERIOD_1Hz.
- */
-#define BSC_PERIOD_TICKS(DEVICE_TYPE, BSC_MSG_PERIOD)       \
-        ((BSC_DEVICE_TICKS(DEVICE_TYPE)) * (BSC_MSG_PERIOD))
-
-/**@brief Initialize an ANT channel configuration structure for the BSC profile (Display).
- *
- * @param[in]  NAME                 Name of related instance.
- * @param[in]  CHANNEL_NUMBER       Number of the channel assigned to the profile instance.
- * @param[in]  TRANSMISSION_TYPE    Type of transmission assigned to the profile instance.
- * @param[in]  DEVICE_TYPE          Type of device. Supported types: @ref BSC_SPEED_DEVICE_TYPE, @ref BSC_CADENCE_DEVICE_TYPE,
- *                                  @ref BSC_COMBINED_DEVICE_TYPE.
- * @param[in]  DEVICE_NUMBER        Number of the device assigned to the profile instance.
- * @param[in]  NETWORK_NUMBER       Number of the network assigned to the profile instance.
- * @param[in]  BSC_MSG_PERIOD       Channel data frequency in Hz. The BSC profile supports only the following frequencies:
- *                                  @ref BSC_MSG_PERIOD_4Hz, @ref BSC_MSG_PERIOD_2Hz, @ref BSC_MSG_PERIOD_1Hz.
- */
-#define BSC_DISP_CHANNEL_CONFIG_DEF(NAME,                                       \
-                                    CHANNEL_NUMBER,                             \
-                                    TRANSMISSION_TYPE,                          \
-                                    DEVICE_TYPE,                                \
-                                    DEVICE_NUMBER,                              \
-                                    NETWORK_NUMBER,                             \
-                                    BSC_MSG_PERIOD)                             \
-static const ant_channel_config_t   NAME##_channel_bsc_disp_config =            \
-    {                                                                           \
-        .channel_number     = (CHANNEL_NUMBER),                                 \
-        .channel_type       = BSC_DISP_CHANNEL_TYPE,                            \
-        .ext_assign         = BSC_EXT_ASSIGN,                                   \
-        .rf_freq            = BSC_ANTPLUS_RF_FREQ,                              \
-        .transmission_type  = (TRANSMISSION_TYPE),                              \
-        .device_type        = (DEVICE_TYPE),                                    \
-        .device_number      = (DEVICE_NUMBER),                                  \
-        .channel_period     = BSC_PERIOD_TICKS(DEVICE_TYPE, BSC_MSG_PERIOD),    \
-        .network_number     = (NETWORK_NUMBER),                                 \
-    }
-#define BSC_DISP_CHANNEL_CONFIG(NAME) &NAME##_channel_bsc_disp_config
-
-/**@brief Initialize an ANT channel configuration structure for the BSC profile (Transmitter).
- *
- * @param[in]  NAME                 Name of related instance.
- * @param[in]  CHANNEL_NUMBER       Number of the channel assigned to the profile instance.
- * @param[in]  TRANSMISSION_TYPE    Type of transmission assigned to the profile instance.
- * @param[in]  DEVICE_TYPE          Type of device. Supported types: @ref BSC_SPEED_DEVICE_TYPE, @ref BSC_CADENCE_DEVICE_TYPE,
- *                                  @ref BSC_COMBINED_DEVICE_TYPE.
- * @param[in]  DEVICE_NUMBER        Number of the device assigned to the profile instance.
- * @param[in]  NETWORK_NUMBER       Number of the network assigned to the profile instance.
- */
-#define BSC_SENS_CHANNEL_CONFIG_DEF(NAME,                                           \
-                                    CHANNEL_NUMBER,                                 \
-                                    TRANSMISSION_TYPE,                              \
-                                    DEVICE_TYPE,                                    \
-                                    DEVICE_NUMBER,                                  \
-                                    NETWORK_NUMBER)                                 \
-static const ant_channel_config_t   NAME##_channel_bsc_sens_config =                \
-    {                                                                               \
-        .channel_number     = (CHANNEL_NUMBER),                                     \
-        .channel_type       = BSC_SENS_CHANNEL_TYPE,                                \
-        .ext_assign         = BSC_EXT_ASSIGN,                                       \
-        .rf_freq            = BSC_ANTPLUS_RF_FREQ,                                  \
-        .transmission_type  = (TRANSMISSION_TYPE),                                  \
-        .device_type        = (DEVICE_TYPE),                                        \
-        .device_number      = (DEVICE_NUMBER),                                      \
-        .channel_period     = BSC_PERIOD_TICKS(DEVICE_TYPE, BSC_MSG_PERIOD_4Hz),    \
-        .network_number     = (NETWORK_NUMBER),                                     \
-    }
-#define BSC_SENS_CHANNEL_CONFIG(NAME) &NAME##_channel_bsc_sens_config
-
-/**@brief Initialize an ANT profile configuration structure for the BSC profile (Display).
- *
- * @param[in]  NAME                 Name of related instance.
- * @param[in]  EVT_HANDLER          Event handler to be called for handling events in the BSC profile.
- */
-#define BSC_DISP_PROFILE_CONFIG_DEF(NAME,                               \
-                                    EVT_HANDLER)                        \
-static ant_bsc_disp_cb_t            NAME##_bsc_disp_cb;                 \
-static const ant_bsc_disp_config_t  NAME##_profile_bsc_disp_config =    \
-    {                                                                   \
-        .p_cb               = &NAME##_bsc_disp_cb,                      \
-        .evt_handler        = (EVT_HANDLER),                            \
-    }
-#define BSC_DISP_PROFILE_CONFIG(NAME) &NAME##_profile_bsc_disp_config
-
-/**@brief Initialize an ANT profile configuration structure for the BSC profile (Sensor).
- *
- * @param[in]  NAME                 Name of related instance.
- * @param[in]  PAGE_1_PRESENT       Determines whether page 1 is included.
- * @param[in]  PAGE_4_PRESENT       Determines whether page 4 is included.
- * @param[in]  MAIN_PAGE_NUMBER     Determines the main data page (@ref ANT_BSC_PAGE_0 or @ref ANT_BSC_PAGE_5 or @ref ANT_BSC_COMB_PAGE_0).
- * @param[in]  EVT_HANDLER          Event handler to be called for handling events in the BSC profile.
- */
-#define BSC_SENS_PROFILE_CONFIG_DEF(NAME,                               \
-                                    PAGE_1_PRESENT,                     \
-                                    PAGE_4_PRESENT,                     \
-                                    MAIN_PAGE_NUMBER,                   \
-                                    EVT_HANDLER)                        \
-static ant_bsc_sens_cb_t            NAME##_bsc_sens_cb;                 \
-static const ant_bsc_sens_config_t  NAME##_profile_bsc_sens_config =    \
-    {                                                                   \
-        .page_1_present     = (PAGE_1_PRESENT),                         \
-        .page_4_present     = (PAGE_4_PRESENT),                         \
-        .main_page_number   = (MAIN_PAGE_NUMBER),                       \
-        .p_cb               = &NAME##_bsc_sens_cb,                      \
-        .evt_handler        = (EVT_HANDLER),                            \
-    }
-#define BSC_SENS_PROFILE_CONFIG(NAME) &NAME##_profile_bsc_sens_config
-
-/**@brief BSC page number type. */
-typedef enum{
-    ANT_BSC_PAGE_0,                         ///< Main data page number 0.
-    ANT_BSC_PAGE_1,                         ///< Background data page number 1. This page is optional.
-    ANT_BSC_PAGE_2,                         ///< Background data page number 2.
-    ANT_BSC_PAGE_3,                         ///< Background data page number 3.
-    ANT_BSC_PAGE_4,                         ///< Background data page number 4. This page is optional.
-    ANT_BSC_PAGE_5,                         ///< Main data page number 5. This page is optional.
-    ANT_BSC_COMB_PAGE_0                     ///< Main data page number 0 for combined speed and cadence sensor.
-} ant_bsc_page_t;
-
-/**@brief BSC profile event type. */
-typedef enum{
-    ANT_BSC_PAGE_0_UPDATED      = ANT_BSC_PAGE_0,       ///< Data page 0 has been updated (Display) or sent (Sensor).
-    ANT_BSC_PAGE_1_UPDATED      = ANT_BSC_PAGE_1,       ///< Data page 0 and page 1 have been updated (Display) or sent (Sensor).
-    ANT_BSC_PAGE_2_UPDATED      = ANT_BSC_PAGE_2,       ///< Data page 0 and page 2 have been updated (Display) or sent (Sensor).
-    ANT_BSC_PAGE_3_UPDATED      = ANT_BSC_PAGE_3,       ///< Data page 0 and page 3 have been updated (Display) or sent (Sensor).
-    ANT_BSC_PAGE_4_UPDATED      = ANT_BSC_PAGE_4,       ///< Data page 0 and page 4 have been updated (Display) or sent (Sensor).
-    ANT_BSC_PAGE_5_UPDATED      = ANT_BSC_PAGE_5,       ///< Data page 0 and page 5 have been updated (Display) or sent (Sensor).
-    ANT_BSC_COMB_PAGE_0_UPDATED = ANT_BSC_COMB_PAGE_0,  ///< Combined Speed and cadence data page has been updated (Display) or sent (Sensor).
-} ant_bsc_evt_t;
-
-// Forward declaration of the ant_bsc_profile_t type.
-typedef struct ant_bsc_profile_s ant_bsc_profile_t;
-
-/**@brief BSC event handler type. */
-typedef void (* ant_bsc_evt_handler_t) (ant_bsc_profile_t *, ant_bsc_evt_t);
-
-#include "ant_bsc_local.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief BSC Display configuration structure. */
-typedef struct
-{
-    ant_bsc_disp_cb_t     * p_cb;               ///< Pointer to the data buffer for internal use.
-    ant_bsc_evt_handler_t   evt_handler;        ///< Event handler to be called for handling events in the BSC profile.
-} ant_bsc_disp_config_t;
-
-/**@brief BSC Sensor configuration structure. */
-typedef struct
-{
-    bool                    page_1_present;     ///< Determines whether page 1 is included.
-    bool                    page_4_present;     ///< Determines whether page 4 is included.
-    ant_bsc_page_t          main_page_number;   ///< Determines the main data page (@ref ANT_BSC_PAGE_0 or @ref ANT_BSC_PAGE_5 or @ref ANT_BSC_COMB_PAGE_0).
-    ant_bsc_sens_cb_t     * p_cb;               ///< Pointer to the data buffer for internal use.
-    ant_bsc_evt_handler_t   evt_handler;        ///< Event handler to be called for handling events in the BSC profile.
-} ant_bsc_sens_config_t;
-
-/**@brief BSC profile structure. */
-struct ant_bsc_profile_s
-{
-    uint8_t                         channel_number; ///< Channel number assigned to the profile.
-    union {
-        ant_bsc_disp_cb_t * p_disp_cb;
-        ant_bsc_sens_cb_t * p_sens_cb;
-    } _cb;                                          ///< Pointer to internal control block.
-    ant_bsc_evt_handler_t           evt_handler;    ///< Event handler to be called for handling events in the BSC profile.
-    ant_bsc_page0_data_t            page_0;         ///< Page 0.
-    ant_bsc_page1_data_t            page_1;         ///< Page 1.
-    ant_bsc_page2_data_t            page_2;         ///< Page 2.
-    ant_bsc_page3_data_t            page_3;         ///< Page 3.
-    ant_bsc_page4_data_t            page_4;         ///< Page 4.
-    ant_bsc_page5_data_t            page_5;         ///< Page 5.
-    ant_bsc_combined_page0_data_t   page_comb_0;    ///< Page 0 for combined speed and cadence sensor.
-};
-
-/** @name Defines for accessing ant_bsc_profile_t member variables
-@{ */
-#define BSC_PROFILE_event_time          page_0.event_time
-#define BSC_PROFILE_rev_count           page_0.rev_count
-#define BSC_PROFILE_operating_time      page_1.operating_time
-#define BSC_PROFILE_manuf_id            page_2.manuf_id
-#define BSC_PROFILE_serial_num          page_2.serial_num
-#define BSC_PROFILE_hw_version          page_3.hw_version
-#define BSC_PROFILE_sw_version          page_3.sw_version
-#define BSC_PROFILE_model_num           page_3.model_num
-#define BSC_PROFILE_fract_bat_volt      page_4.fract_bat_volt
-#define BSC_PROFILE_coarse_bat_volt     page_4.coarse_bat_volt
-#define BSC_PROFILE_bat_status          page_4.bat_status
-#define BSC_PROFILE_stop_indicator      page_5.stop_indicator
-#define BSC_PROFILE_cadence_event_time  page_comb_0.cadence_event_time
-#define BSC_PROFILE_cadence_rev_count   page_comb_0.cadence_rev_count
-#define BSC_PROFILE_speed_event_time    page_comb_0.speed_event_time
-#define BSC_PROFILE_speed_rev_count     page_comb_0.speed_rev_count
-/** @} */
-
-/**@brief Function for initializing the ANT BSC profile instance.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- * @param[in]  p_channel_config Pointer to the ANT channel configuration structure.
- * @param[in]  p_disp_config    Pointer to the BSC display configuration structure.
- *
- * @retval     NRF_SUCCESS      If initialization was successful. Otherwise, an error code is returned.
- */
-ret_code_t ant_bsc_disp_init(ant_bsc_profile_t           * p_profile,
-                             ant_channel_config_t const  * p_channel_config,
-                             ant_bsc_disp_config_t const * p_disp_config);
-
-/**@brief Function for initializing the ANT BSC profile instance.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- * @param[in]  p_channel_config Pointer to the ANT channel configuration structure.
- * @param[in]  p_sens_config    Pointer to the BSC sensor configuration structure.
- *
- * @retval     NRF_SUCCESS      If initialization was successful. Otherwise, an error code is returned.
- */
-ret_code_t ant_bsc_sens_init(ant_bsc_profile_t           * p_profile,
-                             ant_channel_config_t const  * p_channel_config,
-                             ant_bsc_sens_config_t const * p_sens_config);
-
-/**@brief Function for opening the profile instance channel for the ANT BSC Display.
- *
- * Before calling this function, pages should be configured.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- *
- * @retval     NRF_SUCCESS      If the channel was successfully opened. Otherwise, an error code is returned.
- */
-ret_code_t ant_bsc_disp_open(ant_bsc_profile_t * p_profile);
-
-/**@brief Function for opening the profile instance channel for the ANT BSC Sensor.
- *
- * Before calling this function, pages should be configured.
- *
- * @param[in]  p_profile        Pointer to the profile instance.
- *
- * @retval     NRF_SUCCESS      If the channel was successfully opened. Otherwise, an error code is returned.
- */
-ret_code_t ant_bsc_sens_open(ant_bsc_profile_t * p_profile);
-
-/**@brief Function for handling the Sensor ANT events.
- *
- * @details This function handles all events from the ANT stack that are of interest to the Bicycle Speed and Cadence Sensor profile.
- *
- * @param[in]   p_profile       Pointer to the profile instance.
- * @param[in]   p_ant_event     Event received from the ANT stack.
- */
-void ant_bsc_sens_evt_handler(ant_bsc_profile_t * p_profile,
-                              ant_evt_t * p_ant_event);
-
-/**@brief Function for handling the Display ANT events.
- *
- * @details This function handles all events from the ANT stack that are of interest to the Bicycle Speed and Cadence Display profile.
- *
- * @param[in]   p_profile       Pointer to the profile instance.
- * @param[in]   p_ant_event     Event received from the ANT stack.
- */
-void ant_bsc_disp_evt_handler(ant_bsc_profile_t * p_profile,
-                              ant_evt_t * p_ant_event);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_H__
-/** @} */
-

+ 0 - 83
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/ant_bsc_local.h

@@ -1,83 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_LOCAL_H__
-#define ANT_BSC_LOCAL_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "ant_bsc.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup ant_bsc
- * @{
- */
-
-/**@brief BSC Sensor control block. */
-typedef struct
-{
-    uint8_t         device_type;
-    uint8_t         toggle_bit          : 1;
-    ant_bsc_page_t  main_page_number    : 7;
-    uint8_t         page_1_present      : 1;
-    uint8_t         page_4_present      : 1;
-    ant_bsc_page_t  bkgd_page_number    : 6;
-    uint8_t         message_counter;
-}ant_bsc_sens_cb_t;
-
-/**@brief BSC Display control block. */
-typedef struct
-{
-    uint8_t         device_type;
-}ant_bsc_disp_cb_t;
-
-/**
- * @}
- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_LOCAL_H__

+ 0 - 128
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_combined_page_0.c

@@ -1,128 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BSC)
-
-#include "ant_bsc_combined_page_0.h"
-#include "ant_bsc_utils.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BCS_COMBINED_PAGE_0"
-#if ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BSC_COMBINED_PAGE_0_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BSC_COMBINED_PAGE_0_INFO_COLOR
-#else // ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BSC_COMBINED_PAGE_0_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief BSC page 0 data layout structure. */
-typedef struct
-{
-    uint8_t cadence_evt_time_LSB;
-    uint8_t cadence_evt_time_MSB;
-    uint8_t cadence_rev_count_LSB;
-    uint8_t cadence_rev_count_MSB;
-    uint8_t speed_evt_time_LSB;
-    uint8_t speed_evt_time_MSB;
-    uint8_t speed_rev_count_LSB;
-    uint8_t speed_rev_count_MSB;
-}ant_bsc_combined_page0_data_layout_t;
-
-/**@brief Function for printing combined speed and cadence page0 data. */
-static void comb_page0_data_log(ant_bsc_combined_page0_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Cadence Revolution count: %u\r\n",
-                   (unsigned int)p_page_data->cadence_rev_count);
-
-    NRF_LOG_INFO("Cadence event time:       %u.%03us\r\n",
-                   (unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->cadence_event_time),
-                   (unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->cadence_event_time));
-
-    NRF_LOG_INFO("Speed Revolution count:   %u\r\n",
-                   (unsigned int)p_page_data->speed_rev_count);
-
-    NRF_LOG_INFO("Speed event time:         %u.%03us\r\n\n",
-                   (unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->speed_event_time),
-                   (unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->speed_event_time));
-}
-
-void ant_bsc_combined_page_0_encode(uint8_t * p_page_buffer, ant_bsc_combined_page0_data_t const * p_page_data)
-{
-    ant_bsc_combined_page0_data_layout_t * p_outcoming_data = (ant_bsc_combined_page0_data_layout_t *) p_page_buffer;
-
-    uint16_t cadence_event_time = p_page_data->cadence_event_time;
-    uint16_t cadence_rev_count  = p_page_data->cadence_rev_count;
-    uint16_t speed_event_time   = p_page_data->speed_event_time;
-    uint16_t speed_rev_count    = p_page_data->speed_rev_count;
-
-    p_outcoming_data->cadence_evt_time_LSB  = (uint8_t)(cadence_event_time & UINT8_MAX);
-    p_outcoming_data->cadence_evt_time_MSB  = (uint8_t)((cadence_event_time >> 8) & UINT8_MAX);
-    p_outcoming_data->cadence_rev_count_LSB = (uint8_t)(cadence_rev_count & UINT8_MAX);
-    p_outcoming_data->cadence_rev_count_MSB = (uint8_t)((cadence_rev_count >> 8) & UINT8_MAX);
-    p_outcoming_data->speed_evt_time_LSB    = (uint8_t)(speed_event_time & UINT8_MAX);
-    p_outcoming_data->speed_evt_time_MSB    = (uint8_t)((speed_event_time >> 8) & UINT8_MAX);
-    p_outcoming_data->speed_rev_count_LSB   = (uint8_t)(speed_rev_count & UINT8_MAX);
-    p_outcoming_data->speed_rev_count_MSB   = (uint8_t)((speed_rev_count >> 8) & UINT8_MAX);
-
-    comb_page0_data_log(p_page_data);
-}
-
-void ant_bsc_combined_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_combined_page0_data_t * p_page_data)
-{
-    ant_bsc_combined_page0_data_layout_t const * p_incoming_data = (ant_bsc_combined_page0_data_layout_t *)p_page_buffer;
-
-    uint16_t cadence_event_time = (uint16_t)((p_incoming_data->cadence_evt_time_MSB << 8)
-                                  + p_incoming_data->cadence_evt_time_LSB);
-    uint16_t cadence_revolution_count = (uint16_t) ((p_incoming_data->cadence_rev_count_MSB << 8)
-                                        + p_incoming_data->cadence_rev_count_LSB);
-    uint16_t speed_event_time = (uint16_t)((p_incoming_data->speed_evt_time_MSB << 8)
-                                + p_incoming_data->speed_evt_time_LSB);
-    uint16_t speed_revolution_count = (uint16_t) ((p_incoming_data->speed_rev_count_MSB << 8)
-                                      + p_incoming_data->speed_rev_count_LSB);
-
-    p_page_data->cadence_event_time = cadence_event_time;
-    p_page_data->cadence_rev_count  = cadence_revolution_count;
-    p_page_data->speed_event_time   = speed_event_time;
-    p_page_data->speed_rev_count    = speed_revolution_count;
-
-    comb_page0_data_log(p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BSC)

+ 0 - 99
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_combined_page_0.h

@@ -1,99 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_COMBINED_PAGE_0_H__
-#define ANT_BSC_COMBINED_PAGE_0_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bsc_combined_page0 BSC profile page 0 (combined speed & cadence)
- * @{
- * @ingroup ant_sdk_profiles_bsc_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for Bicycle Combined Speed and Cadence data page 0.
- *
- * This structure is used as a common page.
- */
-typedef struct
-{
-    uint16_t cadence_event_time;          ///< Cadence event time.
-    uint16_t cadence_rev_count;           ///< Cadence revolution count.
-    uint16_t speed_event_time;            ///< Speed event time.
-    uint16_t speed_rev_count;             ///< Speed revolution count.
-} ant_bsc_combined_page0_data_t;
-
-/**@brief Initialize page 0.
- */
-#define DEFAULT_ANT_BSC_COMBINED_PAGE0() \
-    (ant_bsc_combined_page0_data_t)      \
-    {                                    \
-        .cadence_event_time = 0,         \
-        .cadence_rev_count  = 0,         \
-        .speed_event_time   = 0,         \
-        .speed_rev_count    = 0,         \
-    }
-
-/**@brief Function for encoding page 0.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bsc_combined_page_0_encode(uint8_t * p_page_buffer, ant_bsc_combined_page0_data_t const * p_page_data);
-
-/**@brief Function for decoding page 0.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bsc_combined_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_combined_page0_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_COMBINED_PAGE_0_H__
-/** @} */

+ 0 - 110
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_0.c

@@ -1,110 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BSC)
-
-#include "ant_bsc_page_0.h"
-#include "ant_bsc_utils.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_0"
-#if ANT_BSC_PAGE_0_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BSC_PAGE_0_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BSC_PAGE_0_INFO_COLOR
-#else // ANT_BSC_PAGE_0_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BSC_PAGE_0_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief BSC page 0 data layout structure. */
-typedef struct
-{
-    uint8_t reserved[3];
-    uint8_t bsc_evt_time_LSB;
-    uint8_t bsc_evt_time_MSB;
-    uint8_t bsc_rev_count_LSB;
-    uint8_t bsc_rev_count_MSB;
-}ant_bsc_page0_data_layout_t;
-
-/**@brief Function for printing speed or cadence page0 data. */
-static void page0_data_log(ant_bsc_page0_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Revolution count:          %u\r\n", (unsigned int)p_page_data->rev_count);
-
-    NRF_LOG_INFO("BSC event time:            %u.%03us\r\n",
-              (unsigned int)ANT_BSC_EVENT_TIME_SEC(p_page_data->event_time),
-              (unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->event_time));
-
-//    NRF_LOG_INFO("%03us\r\n", (unsigned int)ANT_BSC_EVENT_TIME_MSEC(p_page_data->event_time));
-}
-
-void ant_bsc_page_0_encode(uint8_t * p_page_buffer, ant_bsc_page0_data_t const * p_page_data)
-{
-    ant_bsc_page0_data_layout_t * p_outcoming_data = (ant_bsc_page0_data_layout_t *) p_page_buffer;
-    uint16_t                      event_time       = p_page_data->event_time;
-    uint16_t                      rev_count        = p_page_data->rev_count;
-
-    p_outcoming_data->reserved[0]       = UINT8_MAX;
-    p_outcoming_data->reserved[1]       = UINT8_MAX;
-    p_outcoming_data->reserved[2]       = UINT8_MAX;
-    p_outcoming_data->bsc_evt_time_LSB  = (uint8_t)(event_time & UINT8_MAX);
-    p_outcoming_data->bsc_evt_time_MSB  = (uint8_t)((event_time >> 8) & UINT8_MAX);
-    p_outcoming_data->bsc_rev_count_LSB = (uint8_t)(rev_count & UINT8_MAX);
-    p_outcoming_data->bsc_rev_count_MSB = (uint8_t)((rev_count >> 8) & UINT8_MAX);
-
-    page0_data_log(p_page_data);
-}
-
-void ant_bsc_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_page0_data_t * p_page_data)
-{
-    ant_bsc_page0_data_layout_t const * p_incoming_data = (ant_bsc_page0_data_layout_t *)p_page_buffer;
-
-    uint16_t event_time = (uint16_t)((p_incoming_data->bsc_evt_time_MSB << 8)
-                          + p_incoming_data->bsc_evt_time_LSB);
-
-    uint16_t revolution_count = (uint16_t) ((p_incoming_data->bsc_rev_count_MSB << 8)
-                                + p_incoming_data->bsc_rev_count_LSB);
-
-    p_page_data->event_time = event_time;
-    p_page_data->rev_count  = revolution_count;
-
-    page0_data_log(p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BSC)

+ 0 - 95
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_0.h

@@ -1,95 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_PAGE_0_H__
-#define ANT_BSC_PAGE_0_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bsc_page0 BSC profile page 0
- * @{
- * @ingroup ant_sdk_profiles_bsc_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for BSC data page 0.
- *
- * This structure is used as a common page.
- */
-typedef struct
-{
-    uint16_t event_time;            ///< Speed or cadence event time.
-    uint16_t rev_count;             ///< Speed or cadence revolution count.
-} ant_bsc_page0_data_t;
-
-/**@brief Initialize page 0.
- */
-#define DEFAULT_ANT_BSC_PAGE0() \
-    (ant_bsc_page0_data_t)      \
-    {                           \
-        .event_time  = 0,       \
-        .rev_count   = 0        \
-    }
-
-/**@brief Function for encoding page 0.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bsc_page_0_encode(uint8_t * p_page_buffer, ant_bsc_page0_data_t const * p_page_data);
-
-/**@brief Function for decoding page 0.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bsc_page_0_decode(uint8_t const * p_page_buffer, ant_bsc_page0_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_PAGE_0_H__
-/** @} */

+ 0 - 93
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_1.c

@@ -1,93 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BSC)
-
-#include "ant_bsc_page_1.h"
-#include "ant_bsc_utils.h"
-#include "app_util.h"
-#include "nordic_common.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_1"
-#if ANT_BSC_PAGE_1_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BSC_PAGE_1_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BSC_PAGE_1_INFO_COLOR
-#else // ANT_BSC_PAGE_1_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BSC_PAGE_1_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief BSC page 1 data layout structure. */
-typedef struct
-{
-    uint8_t cumulative_operating_time[3];
-    uint8_t reserved[4];
-}ant_bsc_page1_data_layout_t;
-
-/**@brief Function for printing speed or cadence page1 data. */
-static void page1_data_log(ant_bsc_page1_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Cumulative operating time: %ud %uh %um %us\r\n",
-              (unsigned int)ANT_BSC_OPERATING_DAYS(p_page_data->operating_time),
-              (unsigned int)ANT_BSC_OPERATING_HOURS(p_page_data->operating_time),
-              (unsigned int)ANT_BSC_OPERATING_MINUTES(p_page_data->operating_time),
-              (unsigned int)ANT_BSC_OPERATING_SECONDS(p_page_data->operating_time));
-}
-
-void ant_bsc_page_1_encode(uint8_t * p_page_buffer, ant_bsc_page1_data_t const * p_page_data)
-{
-    ant_bsc_page1_data_layout_t * p_outcoming_data = (ant_bsc_page1_data_layout_t *)p_page_buffer;
-
-    UNUSED_PARAMETER(uint24_encode(p_page_data->operating_time,
-                     p_outcoming_data->cumulative_operating_time));
-    page1_data_log( p_page_data);
-}
-
-void ant_bsc_page_1_decode(uint8_t const * p_page_buffer, ant_bsc_page1_data_t * p_page_data)
-{
-    ant_bsc_page1_data_layout_t const * p_incoming_data = (ant_bsc_page1_data_layout_t *)p_page_buffer;
-
-    p_page_data->operating_time = uint24_decode(p_incoming_data->cumulative_operating_time);
-
-    page1_data_log( p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BSC)
-

+ 0 - 93
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_1.h

@@ -1,93 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_PAGE_1_H__
-#define ANT_BSC_PAGE_1_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bsc_page1 BSC profile page 1
- * @{
- * @ingroup ant_sdk_profiles_bsc_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for BSC data page 1.
- *
- * This structure implements only page 1 specific data.
- */
-typedef struct
-{
-    uint32_t operating_time;        ///< Operating time.
-} ant_bsc_page1_data_t;
-
-/**@brief Initialize page 1.
- */
-#define DEFAULT_ANT_BSC_PAGE1()     \
-    (ant_bsc_page1_data_t)          \
-    {                               \
-        .operating_time      = 0,   \
-    }
-
-/**@brief Function for encoding page 1.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bsc_page_1_encode(uint8_t * p_page_buffer, ant_bsc_page1_data_t const * p_page_data);
-
-/**@brief Function for decoding page 1.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bsc_page_1_decode(uint8_t const * p_page_buffer, ant_bsc_page1_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_PAGE_1_H__
-/** @} */

+ 0 - 95
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_2.c

@@ -1,95 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BSC)
-
-#include "ant_bsc_page_2.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_2"
-#if ANT_BSC_PAGE_2_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BSC_PAGE_2_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BSC_PAGE_2_INFO_COLOR
-#else // ANT_BSC_PAGE_2_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BSC_PAGE_2_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief BSC page 2 data layout structure. */
-typedef struct
-{
-    uint8_t manuf_id;
-    uint8_t serial_num_LSB;
-    uint8_t serial_num_MSB;
-    uint8_t reserved[4];
-}ant_bsc_page2_data_layout_t;
-
-/**@brief Function for printing speed or cadence page2 data. */
-static void page2_data_log(ant_bsc_page2_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Manufacturer ID:           %u\r\n", (unsigned int)p_page_data->manuf_id);
-    NRF_LOG_INFO("Serial No (upper 16-bits): 0x%X\r\n",
-              (unsigned int)p_page_data->serial_num);
-}
-
-void ant_bsc_page_2_encode(uint8_t * p_page_buffer, ant_bsc_page2_data_t const * p_page_data)
-{
-    ant_bsc_page2_data_layout_t * p_outcoming_data = (ant_bsc_page2_data_layout_t *)p_page_buffer;
-    uint32_t serial_num                            = p_page_data->serial_num;
-
-    p_outcoming_data->manuf_id       = (uint8_t)p_page_data->manuf_id;
-    p_outcoming_data->serial_num_LSB = (uint8_t)(serial_num & UINT8_MAX);
-    p_outcoming_data->serial_num_MSB = (uint8_t)((serial_num >> 8) & UINT8_MAX);
-
-    page2_data_log( p_page_data);
-}
-
-void ant_bsc_page_2_decode(uint8_t const * p_page_buffer, ant_bsc_page2_data_t * p_page_data)
-{
-    ant_bsc_page2_data_layout_t const * p_incoming_data = (ant_bsc_page2_data_layout_t *)p_page_buffer;
-    uint32_t serial_num = (uint32_t)((p_incoming_data->serial_num_MSB << 8)
-                          + p_incoming_data->serial_num_LSB);
-
-    p_page_data->manuf_id            = (uint32_t)p_incoming_data->manuf_id;
-    p_page_data->serial_num          = serial_num;
-
-    page2_data_log( p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BSC)

+ 0 - 95
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_2.h

@@ -1,95 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_PAGE_2_H__
-#define ANT_BSC_PAGE_2_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bsc_page2 BSC profile page 2
- * @{
- * @ingroup ant_sdk_profiles_bsc_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for BSC data page 2.
- *
- * This structure implements only page 2 specific data.
- */
-typedef struct
-{
-    uint8_t  manuf_id;              ///< Manufacturer ID.
-    uint16_t serial_num;            ///< Serial number.
-} ant_bsc_page2_data_t;
-
-/**@brief Initialize page 2.
- */
-#define DEFAULT_ANT_BSC_PAGE2()     \
-    (ant_bsc_page2_data_t)          \
-    {                               \
-        .manuf_id      = 0,         \
-        .serial_num    = 0,         \
-    }
-
-/**@brief Function for encoding page 2.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bsc_page_2_encode(uint8_t * p_page_buffer, ant_bsc_page2_data_t const * p_page_data);
-
-/**@brief Function for decoding page 2.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bsc_page_2_decode(uint8_t const * p_page_buffer, ant_bsc_page2_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_PAGE_2_H__
-/** @} */

+ 0 - 93
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_3.c

@@ -1,93 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BSC)
-
-#include "ant_bsc_page_3.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_3"
-#if ANT_BSC_PAGE_3_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BSC_PAGE_3_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BSC_PAGE_3_INFO_COLOR
-#else // ANT_BSC_PAGE_3_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BSC_PAGE_3_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief BSC page 3 data layout structure. */
-typedef struct
-{
-    uint8_t hw_version;
-    uint8_t sw_version;
-    uint8_t model_num;
-    uint8_t reserved[4];
-}ant_bsc_page3_data_layout_t;
-
-/**@brief Function for printing speed or cadence page3 data. */
-static void page3_data_log(ant_bsc_page3_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Hardware Rev ID:           %u\r\n", (unsigned int)p_page_data->hw_version);
-    NRF_LOG_INFO("Model Number:              %u\r\n", (unsigned int)p_page_data->model_num);
-    NRF_LOG_INFO("Software Ver ID:           %u\r\n", (unsigned int)p_page_data->sw_version);
-}
-
-void ant_bsc_page_3_encode(uint8_t * p_page_buffer, ant_bsc_page3_data_t const * p_page_data)
-{
-    ant_bsc_page3_data_layout_t * p_outcoming_data = (ant_bsc_page3_data_layout_t *)p_page_buffer;
-
-    p_outcoming_data->hw_version = (uint8_t)p_page_data->hw_version;
-    p_outcoming_data->sw_version = (uint8_t)p_page_data->sw_version;
-    p_outcoming_data->model_num  = (uint8_t)p_page_data->model_num;
-
-    page3_data_log( p_page_data);
-}
-
-void ant_bsc_page_3_decode(uint8_t const * p_page_buffer, ant_bsc_page3_data_t * p_page_data)
-{
-    ant_bsc_page3_data_layout_t const * p_incoming_data = (ant_bsc_page3_data_layout_t *)p_page_buffer;
-
-    p_page_data->hw_version          = (uint32_t)p_incoming_data->hw_version;
-    p_page_data->sw_version          = (uint32_t)p_incoming_data->sw_version;
-    p_page_data->model_num           = (uint32_t)p_incoming_data->model_num;
-
-    page3_data_log( p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BSC)

+ 0 - 97
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_3.h

@@ -1,97 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_PAGE_3_H__
-#define ANT_BSC_PAGE_3_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bsc_page3 BSC profile page 3
- * @{
- * @ingroup ant_sdk_profiles_bsc_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for BSC data page 3.
- *
- * This structure implements only page 3 specific data.
- */
-typedef struct
-{
-   uint8_t hw_version;             ///< Hardware version.
-   uint8_t sw_version;             ///< Software version.
-   uint8_t model_num;              ///< Model number.
-} ant_bsc_page3_data_t;
-
-/**@brief Initialize page 3.
- */
-#define DEFAULT_ANT_BSC_PAGE3()     \
-    (ant_bsc_page3_data_t)          \
-    {                               \
-        .hw_version    = 0,         \
-        .sw_version    = 0,         \
-        .model_num     = 0,         \
-    }
-
-/**@brief Function for encoding page 3.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bsc_page_3_encode(uint8_t * p_page_buffer, ant_bsc_page3_data_t const * p_page_data);
-
-/**@brief Function for decoding page 3.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bsc_page_3_decode(uint8_t const * p_page_buffer, ant_bsc_page3_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_PAGE_3_H__
-/** @} */

+ 0 - 103
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_4.c

@@ -1,103 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BSC)
-
-#include "ant_bsc_page_4.h"
-#include "ant_bsc_utils.h"
-#include "app_util.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_4"
-#if ANT_BSC_PAGE_4_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BSC_PAGE_4_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BSC_PAGE_4_INFO_COLOR
-#else // ANT_BSC_PAGE_4_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BSC_PAGE_4_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief BSC page 4 data layout structure. */
-typedef struct
-{
-    uint8_t reserved_byte;
-    uint8_t fract_bat_volt;
-    uint8_t coarse_bat_volt   : 4;
-    uint8_t bat_status        : 3;
-    uint8_t bitfield_reserved : 1;
-    uint8_t reserved[4];
-}ant_bsc_page4_data_layout_t;
-
-/* Display precission must be updated. */
-STATIC_ASSERT(ANT_BSC_BAT_VOLTAGE_PRECISION == 1000);
-
-/**@brief Function for printing speed or cadence page4 data. */
-static void page4_data_log( ant_bsc_page4_data_t const * p_page_data)
-{
-    NRF_LOG_INFO("Battery voltage:           %u.%03uV\r\n",
-              (unsigned int)p_page_data->coarse_bat_volt,
-              (unsigned int)ANT_BSC_BAT_VOLTAGE_FRACTION_MV(p_page_data->fract_bat_volt));
-    NRF_LOG_INFO("Battery status:            %u\r\n", (unsigned int)p_page_data->bat_status);
-}
-
-void ant_bsc_page_4_encode(uint8_t * p_page_buffer, ant_bsc_page4_data_t const * p_page_data)
-{
-    ant_bsc_page4_data_layout_t * p_outcoming_data = (ant_bsc_page4_data_layout_t *)p_page_buffer;
-
-    p_outcoming_data->reserved_byte     = UINT8_MAX;
-    p_outcoming_data->fract_bat_volt    = p_page_data->fract_bat_volt;
-    p_outcoming_data->coarse_bat_volt   = p_page_data->coarse_bat_volt;
-    p_outcoming_data->bat_status        = p_page_data->bat_status;
-    p_outcoming_data->bitfield_reserved = 0;
-
-    page4_data_log( p_page_data);
-}
-
-void ant_bsc_page_4_decode(uint8_t const * p_page_buffer, ant_bsc_page4_data_t * p_page_data)
-{
-    ant_bsc_page4_data_layout_t const * p_incoming_data = (ant_bsc_page4_data_layout_t *)p_page_buffer;
-
-    p_page_data->fract_bat_volt  = p_incoming_data->fract_bat_volt;
-    p_page_data->coarse_bat_volt = p_incoming_data->coarse_bat_volt;
-    p_page_data->bat_status      = p_incoming_data->bat_status;
-
-    page4_data_log( p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BSC)

+ 0 - 113
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_4.h

@@ -1,113 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_PAGE_4_H__
-#define ANT_BSC_PAGE_4_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bsc_page4 BSC profile page 4
- * @{
- * @ingroup ant_sdk_profiles_bsc_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief BSC profile battery status.
- *
- * This enum represents possible battery status values for the ANT BSC profile.
- */
-typedef enum
-{
-    RESERVED0               = 0,    ///< Reserved.
-    BSC_BAT_STATUS_NEW      = 1,    ///< Battery status: new.
-    BSC_BAT_STATUS_GOOD     = 2,    ///< Battery status: good.
-    BSC_BAT_STATUS_OK       = 3,    ///< Battery status: ok.
-    BSC_BAT_STATUS_LOW      = 4,    ///< Battery status: low.
-    BSC_BAT_STATUS_CRITICAL = 5,    ///< Battery status: critical.
-    RESERVED1               = 6,    ///< Reserved.
-    BSC_BAT_STATUS_INVALID  = 7     ///< Invalid battery status.
-} ant_bsc_bat_status_t;
-
-/**@brief Data structure for BSC data page 4.
- *
- * This structure implements only page 4 specific data.
- */
-typedef struct
-{
-    uint8_t  fract_bat_volt;        ///< Fractional battery voltage.
-    uint8_t  coarse_bat_volt : 4;   ///< Coarse battery voltage.
-    uint8_t  bat_status      : 3;   ///< Battery status.
-} ant_bsc_page4_data_t;
-
-/**@brief Initialize page 4.
- */
-#define DEFAULT_ANT_BSC_PAGE4()                 \
-    (ant_bsc_page4_data_t)                      \
-    {                                           \
-        .fract_bat_volt = 0,                    \
-        .coarse_bat_volt = 0,                   \
-        .bat_status = BSC_BAT_STATUS_INVALID    \
-    }
-
-/**@brief Function for encoding page 4.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bsc_page_4_encode(uint8_t * p_page_buffer, ant_bsc_page4_data_t const * p_page_data);
-
-/**@brief Function for decoding page 4.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bsc_page_4_decode(uint8_t const * p_page_buffer, ant_bsc_page4_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_PAGE_4_H__
-/** @} */

+ 0 - 96
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_5.c

@@ -1,96 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "sdk_common.h"
-#if NRF_MODULE_ENABLED(ANT_BSC)
-
-#include "ant_bsc_page_5.h"
-#include "ant_bsc_utils.h"
-
-#define NRF_LOG_MODULE_NAME "ANT_BCS_PAGE_5"
-#if ANT_BSC_PAGE_5_LOG_ENABLED
-#define NRF_LOG_LEVEL       ANT_BSC_PAGE_5_LOG_LEVEL
-#define NRF_LOG_INFO_COLOR  ANT_BSC_PAGE_5_INFO_COLOR
-#else // ANT_BSC_PAGE_5_LOG_ENABLED
-#define NRF_LOG_LEVEL       0
-#endif // ANT_BSC_PAGE_5_LOG_ENABLED
-#include "nrf_log.h"
-
-/**@brief BSC profile page 5 bitfields definitions. */
-#define ANT_BSC_STOP_IND_MASK       0x01
-
-/**@brief BSC page 5 data layout structure. */
-typedef struct
-{
-    uint8_t flags;
-    uint8_t reserved[6];
-}ant_bsc_page5_data_layout_t;
-
-/**@brief Function for printing speed or cadence page5 data. */
-static void page5_data_log(ant_bsc_page5_data_t const * p_page_data)
-{
-    if (p_page_data->stop_indicator)
-    {
-        NRF_LOG_INFO("Bicycle stopped.\r\n");
-    }
-    else
-    {
-        NRF_LOG_INFO("Bicycle moving.\r\n");
-    }
-}
-
-void ant_bsc_page_5_encode(uint8_t * p_page_buffer, ant_bsc_page5_data_t const * p_page_data)
-{
-    ant_bsc_page5_data_layout_t * p_outcoming_data = (ant_bsc_page5_data_layout_t *)p_page_buffer;
-
-    p_outcoming_data->flags = (uint8_t)p_page_data->stop_indicator;
-
-    page5_data_log( p_page_data);
-}
-
-void ant_bsc_page_5_decode(uint8_t const * p_page_buffer, ant_bsc_page5_data_t * p_page_data)
-{
-    ant_bsc_page5_data_layout_t const * p_incoming_data = (ant_bsc_page5_data_layout_t *)p_page_buffer;
-
-    p_page_data->stop_indicator  = (p_incoming_data->flags) & ANT_BSC_STOP_IND_MASK;
-
-    page5_data_log( p_page_data);
-}
-
-#endif // NRF_MODULE_ENABLED(ANT_BSC)

+ 0 - 95
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_page_5.h

@@ -1,95 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_PAGE_5_H__
-#define ANT_BSC_PAGE_5_H__
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bsc_page5 BSC profile page 5
- * @{
- * @ingroup ant_sdk_profiles_bsc_pages
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief Data structure for BSC data page 5.
- *
- * This structure implements only page 5 specific data.
- */
-typedef struct
-{
-    uint8_t  stop_indicator:1;      ///< Stop indication bit.
-    uint8_t  reserved:7;            ///< Reserved.
-} ant_bsc_page5_data_t;
-
-/**@brief Initialize page 5.
- */
-#define DEFAULT_ANT_BSC_PAGE5()     \
-    (ant_bsc_page5_data_t)          \
-    {                               \
-        .stop_indicator = 0,        \
-        .reserved = 0,              \
-    }
-
-/**@brief Function for encoding page 5.
- *
- * @param[in]  p_page_data      Pointer to the page data.
- * @param[out] p_page_buffer    Pointer to the data buffer.
- */
-void ant_bsc_page_5_encode(uint8_t * p_page_buffer, ant_bsc_page5_data_t const * p_page_data);
-
-/**@brief Function for decoding page 5.
- *
- * @param[in]  p_page_buffer    Pointer to the data buffer.
- * @param[out] p_page_data      Pointer to the page data.
- */
-void ant_bsc_page_5_decode(uint8_t const * p_page_buffer, ant_bsc_page5_data_t * p_page_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_PAGE_5_H__
-/** @} */

+ 0 - 69
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/pages/ant_bsc_pages.h

@@ -1,69 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef __ANT_BSC_PAGES_H
-#define __ANT_BSC_PAGES_H
-
-/** @file
- *
- * @defgroup ant_sdk_profiles_bsc_pages Bicycle Speed and Cadence profile pages
- * @{
- * @ingroup ant_bsc
- * @brief This module implements functions for the BSC data pages.
- */
-
-#include "ant_bsc_page_0.h"
-#include "ant_bsc_page_1.h"
-#include "ant_bsc_page_2.h"
-#include "ant_bsc_page_3.h"
-#include "ant_bsc_page_4.h"
-#include "ant_bsc_page_5.h"
-#include "ant_bsc_combined_page_0.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __ANT_BSC_PAGES_H
-/** @} */

+ 0 - 280
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/simulator/ant_bsc_simulator.c

@@ -1,280 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#include "ant_bsc_simulator.h"
-#include "ant_bsc_utils.h"
-#include "app_util.h"
-
-#define ITERATION_ANT_CYCLES(DEVICE_TYPE) \
-        (BSC_PERIOD_TICKS(DEVICE_TYPE, BSC_MSG_PERIOD_4Hz)) ///< period of calculation [1/32678 s], defined in ANT device profile
-                                                            //   use the same DEVICE TYPE as in profile definition
-#define ITERATION_PERIOD(DEVICE_TYPE) \
-        ((ITERATION_ANT_CYCLES(DEVICE_TYPE)) * 1024 / ANT_CLOCK_FREQUENCY) ///< integer part of calculation's period [1/1024 s]
-#define ITERATION_FRACTION(DEVICE_TYPE) \
-        ((ITERATION_ANT_CYCLES(DEVICE_TYPE)) * 1024 % ANT_CLOCK_FREQUENCY) ///< fractional part of calculation's period [1/32678 s]
-
-#define SPEED_SIM_MIN_VAL                       0u      ///< speed simulation minimum value [m/s]
-#define SPEED_SIM_MAX_VAL                       16u     ///< speed simulation maximum value [m/s]
-#define SPEED_SIM_INCREMENT                     1u      ///< speed simulation value increment [m/s]
-#define CADENCE_SIM_MIN_VAL                     70u     ///< cadence simulation minimum value [rpm]
-#define CADENCE_SIM_MAX_VAL                     120u    ///< cadence simulation maximum value [rpm]
-#define CADENCE_SIM_INCREMENT                   1u      ///< cadence simulation value increment [rpm]
-#define WHEEL_CIRCUMFERENCE                     1766u   ///< bike wheel circumference [mm]
-#define MM_TO_METERS(MM_VAL)                    ((MM_VAL) / 1000u)
-#define TWO_SEC_TO_TICKS                        2048    ///< number of [1/1024s] ticks in 2 sec period
-#define CUMULATIVE_TIME_UNIT                    2       ///< cumulative time unit
-
-void ant_bsc_simulator_init(ant_bsc_simulator_t           * p_simulator,
-                            ant_bsc_simulator_cfg_t const * p_config,
-                            bool                            auto_change)
-{
-    p_simulator->p_profile                     = p_config->p_profile;
-    p_simulator->_cb.auto_change               = auto_change;
-    p_simulator->_cb.speed_sim_val             = SPEED_SIM_MIN_VAL;
-    p_simulator->_cb.cadence_sim_val           = CADENCE_SIM_MIN_VAL;
-    p_simulator->_cb.time_since_last_s_evt     = 0;
-    p_simulator->_cb.fraction_since_last_s_evt = 0;
-    p_simulator->_cb.time_since_last_c_evt     = 0;
-    p_simulator->_cb.fraction_since_last_c_evt = 0;
-    p_simulator->_cb.device_type               = p_config->device_type;
-
-    p_simulator->_cb.sensorsim_s_cfg.min          = SPEED_SIM_MIN_VAL;
-    p_simulator->_cb.sensorsim_s_cfg.max          = SPEED_SIM_MAX_VAL;
-    p_simulator->_cb.sensorsim_s_cfg.incr         = SPEED_SIM_INCREMENT;
-    p_simulator->_cb.sensorsim_s_cfg.start_at_max = false;
-    sensorsim_init(&(p_simulator->_cb.sensorsim_s_state),
-                   &(p_simulator->_cb.sensorsim_s_cfg));
-    p_simulator->_cb.sensorsim_c_cfg.min          = CADENCE_SIM_MIN_VAL;
-    p_simulator->_cb.sensorsim_c_cfg.max          = CADENCE_SIM_MAX_VAL;
-    p_simulator->_cb.sensorsim_c_cfg.incr         = CADENCE_SIM_INCREMENT;
-    p_simulator->_cb.sensorsim_c_cfg.start_at_max = false;
-    p_simulator->_cb.stop_cnt                     = 0;
-    sensorsim_init(&(p_simulator->_cb.sensorsim_c_state),
-                   &(p_simulator->_cb.sensorsim_c_cfg));
-}
-
-
-void ant_bsc_simulator_one_iteration(ant_bsc_simulator_t * p_simulator)
-{
-
-    // Set constant battery voltage
-    p_simulator->p_profile->BSC_PROFILE_coarse_bat_volt = 2;
-    p_simulator->p_profile->BSC_PROFILE_fract_bat_volt  = 200;
-    p_simulator->p_profile->BSC_PROFILE_bat_status      = BSC_BAT_STATUS_GOOD;
-
-    // Calculate speed and cadence values
-    if (p_simulator->_cb.auto_change)
-    {
-        p_simulator->_cb.speed_sim_val   = sensorsim_measure(&(p_simulator->_cb.sensorsim_s_state),
-                                                            &(p_simulator->_cb.sensorsim_s_cfg));
-        p_simulator->_cb.cadence_sim_val = sensorsim_measure(&(p_simulator->_cb.sensorsim_c_state),
-                                                            &(p_simulator->_cb.sensorsim_c_cfg));
-    }
-    else
-    {
-        p_simulator->_cb.speed_sim_val   = p_simulator->_cb.sensorsim_s_state.current_val;
-        p_simulator->_cb.cadence_sim_val = p_simulator->_cb.sensorsim_c_state.current_val;
-    }
-
-    // Simulate bicycle stopped for around 10s and go for around 5s only in auto-simulation
-    if (p_simulator->_cb.auto_change)
-    {
-        if ((p_simulator->p_profile->_cb.p_sens_cb->main_page_number == ANT_BSC_PAGE_5) &&
-            (p_simulator->_cb.stop_cnt++ < 40))
-        {
-            p_simulator->_cb.speed_sim_val                     = 0;
-            p_simulator->_cb.cadence_sim_val                   = 0;
-        }
-        else
-        {
-            if (p_simulator->_cb.stop_cnt == 60)
-            {
-               p_simulator->_cb.stop_cnt = 0;
-            }
-        }
-    }
-    if (p_simulator->_cb.speed_sim_val == 0)
-    {
-        p_simulator->p_profile->BSC_PROFILE_stop_indicator = 1;
-    }
-    else
-    {
-        p_simulator->p_profile->BSC_PROFILE_stop_indicator = 0;
-    }
-
-    // @note: Take a local copy within scope in order to assist the compiler in variable register
-    // allocation.
-    const uint32_t computed_speed   = p_simulator->_cb.speed_sim_val;
-    const uint32_t computed_cadence = p_simulator->_cb.cadence_sim_val;
-
-    // @note: This implementation assumes that the current instantaneous speed/cadence can vary and this
-    // function is called with static frequency.
-    // value and the speed/cadence pulse interval is derived from it. The computation is based on 60
-    // seconds in a minute and the used time base is 1/1024 seconds.
-    const uint32_t current_speed_pulse_interval   =
-                       MM_TO_METERS((WHEEL_CIRCUMFERENCE * 1024u) / computed_speed);
-    const uint32_t current_cadence_pulse_interval = (60u * 1024u) / computed_cadence;
-
-    //update time from last evt detected
-    p_simulator->_cb.time_since_last_s_evt += ITERATION_PERIOD(p_simulator->_cb.device_type);
-    p_simulator->_cb.time_since_last_c_evt += ITERATION_PERIOD(p_simulator->_cb.device_type);
-
-    // extended calculation by fraction make calculating accurate in long time perspective
-    p_simulator->_cb.fraction_since_last_s_evt += ITERATION_FRACTION(p_simulator->_cb.device_type);
-    p_simulator->_cb.fraction_since_last_c_evt += ITERATION_FRACTION(p_simulator->_cb.device_type);
-
-    uint32_t add_period = p_simulator->_cb.fraction_since_last_s_evt / ANT_CLOCK_FREQUENCY;
-    if (add_period > 0)
-    {
-        p_simulator->_cb.time_since_last_s_evt++;
-        p_simulator->_cb.fraction_since_last_s_evt %= ANT_CLOCK_FREQUENCY;
-    }
-
-    add_period = p_simulator->_cb.fraction_since_last_c_evt / ANT_CLOCK_FREQUENCY;
-    if (add_period > 0)
-    {
-        p_simulator->_cb.time_since_last_c_evt++;
-        p_simulator->_cb.fraction_since_last_c_evt %= ANT_CLOCK_FREQUENCY;
-    }
-
-    // Calculate cumulative time based on time since last event (from profile data) in [1/1024] ticks
-    int16_t diff = p_simulator->p_profile->BSC_PROFILE_event_time -
-                   p_simulator->_cb.prev_time_since_evt;
-    p_simulator->_cb.prev_time_since_evt = p_simulator->p_profile->BSC_PROFILE_event_time;
-
-    if (diff >= 0)       // Check for time count overflow
-    {
-        // No overflow
-        p_simulator->_cb.cumulative_time += diff / TWO_SEC_TO_TICKS;
-        p_simulator->_cb.cumulative_time_frac += diff % TWO_SEC_TO_TICKS;
-    }
-    else
-    {
-        p_simulator->_cb.cumulative_time      += (UINT16_MAX + diff) / TWO_SEC_TO_TICKS;
-        p_simulator->_cb.cumulative_time_frac += (UINT16_MAX + diff) % TWO_SEC_TO_TICKS;
-    }
-    // Check fraction
-    if ((p_simulator->_cb.cumulative_time_frac / TWO_SEC_TO_TICKS) > 0)
-    {
-        p_simulator->_cb.cumulative_time      += p_simulator->_cb.cumulative_time_frac / TWO_SEC_TO_TICKS;
-        p_simulator->_cb.cumulative_time_frac %= TWO_SEC_TO_TICKS;
-    }
-    // Update page data if necessary
-    if (p_simulator->_cb.cumulative_time != p_simulator->p_profile->BSC_PROFILE_operating_time)
-    {
-        p_simulator->p_profile->BSC_PROFILE_operating_time = p_simulator->_cb.cumulative_time;
-    }
-
-    //calc number of events as will fill
-    uint32_t new_s_events           = p_simulator->_cb.time_since_last_s_evt /
-                                      current_speed_pulse_interval;
-    uint32_t add_speed_event_time   = new_s_events * current_speed_pulse_interval;
-    if ((new_s_events > 0) && ((p_simulator->_cb.device_type == BSC_SPEED_DEVICE_TYPE) ||
-                               (p_simulator->_cb.device_type == BSC_COMBINED_DEVICE_TYPE)))
-    {
-        p_simulator->p_profile->BSC_PROFILE_rev_count       += new_s_events;
-        p_simulator->p_profile->BSC_PROFILE_speed_rev_count += new_s_events;
-
-        // Current speed event time is the previous event time plus the current speed
-        // pulse interval.
-        uint32_t current_speed_event_time = p_simulator->p_profile->BSC_PROFILE_event_time +
-                                            add_speed_event_time;
-        // Set current event time.
-        p_simulator->p_profile->BSC_PROFILE_event_time = current_speed_event_time; // <- B<4,5> <-
-
-        current_speed_event_time = p_simulator->p_profile->BSC_PROFILE_speed_event_time +
-                                   add_speed_event_time;
-        // Set current event time for combined device.
-        p_simulator->p_profile->BSC_PROFILE_speed_event_time = current_speed_event_time;
-
-        p_simulator->_cb.time_since_last_s_evt -= add_speed_event_time;
-    }
-
-    uint32_t new_c_events           = p_simulator->_cb.time_since_last_c_evt /
-                                      current_cadence_pulse_interval;
-    uint32_t add_cadence_event_time = new_c_events * current_cadence_pulse_interval;
-    if ((new_c_events > 0) && ((p_simulator->_cb.device_type == BSC_CADENCE_DEVICE_TYPE) ||
-                               (p_simulator->_cb.device_type == BSC_COMBINED_DEVICE_TYPE)))
-    {
-        p_simulator->p_profile->BSC_PROFILE_rev_count         += new_c_events;
-        p_simulator->p_profile->BSC_PROFILE_cadence_rev_count += new_c_events;
-
-        // Current speed event time is the previous event time plus the current speed
-        // pulse interval.
-        uint32_t current_cadence_event_time = p_simulator->p_profile->BSC_PROFILE_event_time +
-                                              add_cadence_event_time;
-        // Set current event time.
-        p_simulator->p_profile->BSC_PROFILE_event_time = current_cadence_event_time; //<- B<4,5> <-
-
-        current_cadence_event_time = p_simulator->p_profile->BSC_PROFILE_cadence_event_time +
-                                     add_cadence_event_time;
-        // Set current event time for combined device.
-        p_simulator->p_profile->BSC_PROFILE_cadence_event_time = current_cadence_event_time;
-
-        p_simulator->_cb.time_since_last_c_evt -= add_cadence_event_time;
-    }
-}
-
-
-void ant_bsc_simulator_increment(ant_bsc_simulator_t * p_simulator)
-{
-    if (!p_simulator->_cb.auto_change)
-    {
-        // Speed
-         sensorsim_increment(&(p_simulator->_cb.sensorsim_s_state),
-                             &(p_simulator->_cb.sensorsim_s_cfg));
-        // Cadence
-         sensorsim_increment(&(p_simulator->_cb.sensorsim_c_state),
-                             &(p_simulator->_cb.sensorsim_c_cfg));
-    }
-}
-
-
-void ant_bsc_simulator_decrement(ant_bsc_simulator_t * p_simulator)
-{
-    if (!p_simulator->_cb.auto_change)
-    {
-        // Speed
-         sensorsim_decrement(&(p_simulator->_cb.sensorsim_s_state),
-                             &(p_simulator->_cb.sensorsim_s_cfg));
-        // Cadence
-         sensorsim_decrement(&(p_simulator->_cb.sensorsim_c_state),
-                             &(p_simulator->_cb.sensorsim_c_cfg));
-    }
-}

+ 0 - 120
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/simulator/ant_bsc_simulator.h

@@ -1,120 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_SIMULATOR_H__
-#define ANT_BSC_SIMULATOR_H__
-
-/** @file
- *
- * @defgroup ant_sdk_bsc_simulator ANT BSC simulator
- * @{
- * @ingroup ant_sdk_simulators
- * @brief ANT BSC simulator module.
- *
- * @details This module simulates a pulse for the ANT Bicycle Speed and Cadence profile. The module
- * calculates abstract values, which are handled by the BSC pages data model to ensure that
- * they are compatible. It provides a handler for changing the cadence and speed values manually
- * as well as functionality to change the values automatically.
- *
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "ant_bsc.h"
-#include "ant_bsc_utils.h"
-#include "sensorsim.h"
-#include "ant_bsc_simulator_local.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**@brief BSC simulator configuration structure. */
-typedef struct
-{
-    ant_bsc_profile_t * p_profile;      ///< Related profile.
-    uint8_t             device_type;    ///< BSC device type (must be consistent with the type chosen for the profile). Supported types:
-                                        //   @ref BSC_SPEED_DEVICE_TYPE, @ref BSC_CADENCE_DEVICE_TYPE, @ref BSC_COMBINED_DEVICE_TYPE.
-} ant_bsc_simulator_cfg_t;
-
-/**@brief BSC simulator structure. */
-typedef struct
-{
-    ant_bsc_profile_t    * p_profile;   ///< Related profile.
-    ant_bsc_simulator_cb_t _cb;         ///< Internal control block.
-} ant_bsc_simulator_t;
-
-
-/**@brief Function for initializing the ANT BSC simulator instance.
- *
- * @param[in]  p_simulator      Pointer to the simulator instance.
- * @param[in]  p_config         Pointer to the simulator configuration structure.
- * @param[in]  auto_change      Enable or disable automatic changes of speed or cadence.
- */
-void ant_bsc_simulator_init(ant_bsc_simulator_t           * p_simulator,
-                            ant_bsc_simulator_cfg_t const * p_config,
-                            bool                            auto_change);
-
-/**@brief Function for simulating a device event.
- *
- * @details Based on this event, the transmitter data is simulated.
- *
- * This function should be called in the BSC Sensor event handler.
- */
-void ant_bsc_simulator_one_iteration(ant_bsc_simulator_t * p_simulator);
-
-/**@brief Function for incrementing the cadence value.
- *
- * @param[in]  p_simulator      Pointer to the simulator instance.
- */
-void ant_bsc_simulator_increment(ant_bsc_simulator_t * p_simulator);
-
-/**@brief Function for decrementing the cadence value.
- *
- * @param[in]  p_simulator      Pointer to the simulator instance.
- */
-void ant_bsc_simulator_decrement(ant_bsc_simulator_t * p_simulator);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_SIMULATOR_H__
-/** @} */

+ 0 - 79
bsp/nrf52832/nRF5_SDK_13.0.0_04a0bfd/components/ant/ant_profiles/ant_bsc/simulator/ant_bsc_simulator_local.h

@@ -1,79 +0,0 @@
-/**
- * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
- * 
- * 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, except as embedded into a Nordic
- *    Semiconductor ASA integrated circuit in a product or a software update for
- *    such product, 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 Nordic Semiconductor ASA nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- * 
- * 4. This software, with or without modification, must only be used with a
- *    Nordic Semiconductor ASA integrated circuit.
- * 
- * 5. Any software provided in binary form under this license must not be reverse
- *    engineered, decompiled, modified and/or disassembled.
- * 
- * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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.
- * 
- */
-#ifndef ANT_BSC_SIMULATOR_LOCAL_H__
-#define ANT_BSC_SIMULATOR_LOCAL_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "ant_bsc.h"
-#include "sensorsim.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**@brief BSC simulator control block structure. */
-typedef struct
-{
-    uint8_t             device_type;
-    bool                auto_change;                ///< Cadence will change automatically (if auto_change is set) or manually.
-    uint16_t            speed_sim_val;              ///< Instantaneous speed value.
-    uint16_t            cadence_sim_val;            ///< Instantaneous cadence value.
-    uint32_t            time_since_last_s_evt;      ///< Time since last speed event occurred (integer part).
-    uint64_t            fraction_since_last_s_evt;  ///< Time since last speed event occurred (fractional part).
-    uint32_t            time_since_last_c_evt;      ///< Time since last cadence event occurred (integer part).
-    uint64_t            fraction_since_last_c_evt;  ///< Time since last cadence event occurred (fractional part).
-    sensorsim_state_t   sensorsim_s_state;          ///< State of the simulated speed sensor.
-    sensorsim_cfg_t     sensorsim_s_cfg;            ///< Configuration of the simulated speed sensor.
-    sensorsim_state_t   sensorsim_c_state;          ///< State of the simulated cadence sensor.
-    sensorsim_cfg_t     sensorsim_c_cfg;            ///< Configuration of the simulated cadence sensor.
-    uint16_t            prev_time_since_evt;        ///< Previous value of time since the last event.
-    uint32_t            cumulative_time;            ///< Cumulative time in 2 s ticks used for updating the cumulative time.
-    uint32_t            cumulative_time_frac;       ///< Cumulative time in 2 s ticks (fractional part), used for updating the cumulative time.
-    uint8_t             stop_cnt;                   ///< Counter used for simulating bicycle stopped state.
-} ant_bsc_simulator_cb_t;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANT_BSC_SIMULATOR_LOCAL_H__

Some files were not shown because too many files changed in this diff